折半搜索
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std ;typedef long long ll ;
typedef pair<ll , ll> p2 ;map<ll , ll> m ;
map<ll , ll> m2 ;
ll save[60][10] ;ll n , a , b , x , y ;
void dfs(){ll i ;for(ll num = 1 ; num < (1<<(n/2)) ; num ++ ){ll temp = num ;i = 0 ;ll a1 = 0 , b1 = 0 ;while( temp ){if(temp & 1) a1 += save[i][0] , b1 += save[i][1] ;temp = temp >> 1 ;i ++ ;}a1 = b * a1 - a * b1 ;m[a1] ++ ;}
}
void dfs2(){ll i ;for(ll num = 1 ; num < (1<<(n - n/2)) ; num ++ ){ll temp = num ;i = n/2 ;ll a1 = 0 , b1 = 0 ;while( temp ){if(temp & 1) a1 += save[i][0] , b1 += save[i][1] ;temp = temp >> 1 ;i ++ ;}a1 = b * a1 - a * b1 ;//cout << a1 << endl ;m2[a1] ++ ;//cout << temp << endl ;//cout << num << endl ;}
}long long pow(int n){long long ans =1 ;for(int i = 1 ; i <= n ; i ++ )ans *= (long long)2 ;return ans ;
}
int main(){while(~ scanf("%lld %lld %lld" , &n , &a , &b)){memset(save , 0 , sizeof(save)) ;for(ll i = 0 ; i < n ; i ++ ){scanf("%lld %lld" , &save[i][0] , &save[i][1]) ;}ll ans = 0 ;if( a != 0){m.clear() , m2.clear() ;dfs() ; dfs2() ;map<ll , ll> :: iterator it ;it = m2.begin() ;ans += m[0] + m2[0] ; //+ m[0] * m2[0] ;while(it != m2.end()) {ll a = it->first ;ll b = it->second ;ans += m[-a] * b ;it ++ ;}}else{ll temp = 0 ;for(ll i = 0 ; i < n ; i ++ ) if(!save[i][0]) temp ++ ;ans = (1LL<<temp) - 1 ;///ans = pow(temp) - 1; also fine}printf("%lld\n" , ans ) ;}return 0 ;
}