#include #define rep(i, n) for(ll i = 0; i < ll(n); i++) #define nrep(i, n) for(ll i = 1; i < ll(n + 1); i++) #define rrep(i, n) for(ll i = ll(n) - 1; i >= 0; i--) #define all(x) (x).begin(), (x).end() #define SIZE 2e5 #define INF 2e18 constexpr long long MOD = 1e9 + 7; using namespace std; typedef long long ll; typedef vector iv; typedef vector lv; typedef vector bv; typedef pair ip; typedef vector pv; typedef vector ivv; typedef set ist; typedef set lst; typedef map imp; typedef map lmp; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } ll digsum(ll n) { ll res = 0; while (n > 0) { res += n % 10; n /= 10; } return res; } ll pow(ll x, ll n) { ll ans = 1; while (n) { if (n % 2) ans *= x; x *= x; n >>= 1; } return ans; } map numeric_component(ll N) { map res; for (ll i = 2; i * i <= N; i++) { if (N % i != 0) continue; while (N % i == 0) { res[i]++; N /= i; } } if (N != 1) res[N]++; return res; } iv dx = {-1, 0, 1, 0}; iv dy = {0, -1, 0, 1}; struct edge { int from, to, length; }; void print(iv &a) { for (auto v : a) cout << v << ' '; cout << endl; } bool isblack(int x, int y) { return x & (1 << y); } struct pair_hash { template std::size_t operator () (std::pair const &pair) const { std::size_t h1 = std::hash()(pair.first); std::size_t h2 = std::hash()(pair.second); return h1 ^ h2; } }; int main() { int T; cin >> T; // cout << isblack(2, 0) << endl; while(T--) { int x, y; cin >> x >> y; queue q; q.push({x, y}); unordered_set checked; checked.insert({x, y}); while(!q.empty()){ auto iter = q.front(); q.pop(); rep(i, 4){ auto newx = iter.first + dx[i], newy = iter.second + dy[i]; if(!isblack(newx, newy)) continue; if(checked.find({newx, newy}) != checked.end()) continue; checked.insert({newx, newy}); q.push({newx, newy}); } } cout << checked.size() << endl; } }