#include #include using namespace std; #define rep(i, n) for(int i=0; i #include int main() { int T; cin >> T; rep(test, T) { ll x, y; cin >> x >> y; set> s; s.insert({ x,y }); queue> q; q.push({ x,y }); while (!q.empty()) { ll nowx = q.front()[0]; int nowy = q.front()[1]; q.pop(); if (nowx > 1) { bitset<60> b = nowx - 1; if (b[nowy]&&!s.count({nowx-1, nowy})) { s.insert({ nowx - 1, nowy }); q.push({ nowx - 1 , nowy }); } } if (nowy > 0) { bitset<60>b = nowx; if (b[nowy - 1] && !s.count({ nowx, nowy - 1 })) { s.insert({ nowx, nowy - 1 }); q.push({ nowx, nowy - 1 }); } } if (nowy < 59) { bitset<60> b = nowx; if (b[nowy + 1] && !s.count({ nowx, nowy + 1 })) { s.insert({ nowx, nowy + 1 }); q.push({ nowx, nowy + 1 }); } } if (nowx+1LL < (1LL << 60LL)) { bitset<60> b = nowx + 1; if (b[nowy] && !s.count({ nowx + 1, nowy })) { s.insert({ nowx + 1, nowy }); q.push({ nowx + 1, nowy }); } } } cout << s.size() << endl; } }