#include <iostream>
#include <cstdint>
using namespace std;
const int32_t N = 10;
static_assert(N > 3, "N should be greater than 3");
const int32_t c_limit = 3 * (1 << (N-2)) - 1;
template<size_t s>
int32_t shr(int32_t n) { return n >> s; }
bool cond_1(const int32_t u, const int32_t v) { return (-1 + shr<8>(u)) == (-shr<3>(v) + shr<2>(v)); }
bool cond_2(const int32_t u, const int32_t v) { return ( shr<8>(u) - shr<7>(u)) == ( shr<4>(v) - shr<3>(v)); }
bool cond_3(const int32_t u, const int32_t v) { return (-shr<7>(u) + shr<6>(u)) == (-shr<5>(v) + shr<4>(v)); }
bool cond_4(const int32_t u, const int32_t v) { return ( shr<6>(u) - shr<5>(u)) == ( 1 - shr<8>(v)); }
bool cond_5(const int32_t u, const int32_t v) { return (-shr<5>(u) + shr<4>(u)) == ( 1 - shr<0>(v)); }
bool cond_6(const int32_t u, const int32_t v) { return ( shr<4>(u) - shr<3>(u)) == ( shr<8>(v) + shr<7>(v)); }
bool cond_7(const int32_t u, const int32_t v) { return (-shr<3>(u) + shr<2>(u)) == (-shr<7>(v) + shr<6>(v)); }
bool cond_8(const int32_t u, const int32_t v) { return ( shr<2>(u) - shr<1>(u)) == (-shr<1>(v) + shr<0>(v)); }
bool cond_9(const int32_t u, const int32_t v) { return (-shr<1>(u) + shr<0>(u)) == ( shr<2>(v) - shr<1>(v)); }
bool cond_10(const int32_t u, const int32_t v) { return (-shr<0>(u) + 1) == ( shr<6>(v) - shr<5>(v)); }
int main()
{
size_t count = 0;
for (int32_t u = 767; u <= c_limit; ++u)
{
for (int32_t v = 767; v <= c_limit; ++v)
{
if (cond_1(u, v) && cond_2(u, v) && cond_3(u, v) && cond_4(u, v) && cond_5(u, v) &&
cond_6(u, v) && cond_7(u, v) && cond_8(u, v) && cond_9(u, v) && cond_10(u, v))
{
cout << "(" << u << ", " << v << ")" << endl;
count++;
}
}
}
cout << count << " pairs" << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N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+KHUpIC0gc2hyPDM+KHUpKSA9PSAoIHNocjw4Pih2KSArIHNocjw3Pih2KSk7IH0KYm9vbCBjb25kXzcoY29uc3QgaW50MzJfdCB1LCBjb25zdCBpbnQzMl90IHYpICB7IHJldHVybiAoLXNocjwzPih1KSArIHNocjwyPih1KSkgPT0gKC1zaHI8Nz4odikgKyBzaHI8Nj4odikpOyB9CmJvb2wgY29uZF84KGNvbnN0IGludDMyX3QgdSwgY29uc3QgaW50MzJfdCB2KSAgeyByZXR1cm4gKCBzaHI8Mj4odSkgLSBzaHI8MT4odSkpID09ICgtc2hyPDE+KHYpICsgc2hyPDA+KHYpKTsgfQpib29sIGNvbmRfOShjb25zdCBpbnQzMl90IHUsIGNvbnN0IGludDMyX3QgdikgIHsgcmV0dXJuICgtc2hyPDE+KHUpICsgc2hyPDA+KHUpKSA9PSAoIHNocjwyPih2KSAtIHNocjwxPih2KSk7IH0KYm9vbCBjb25kXzEwKGNvbnN0IGludDMyX3QgdSwgY29uc3QgaW50MzJfdCB2KSB7IHJldHVybiAoLXNocjwwPih1KSArIDEpICAgICAgICAgPT0gKCBzaHI8Nj4odikgLSBzaHI8NT4odikpOyB9CgppbnQgbWFpbigpCnsKICAgc2l6ZV90IGNvdW50ID0gMDsKICAgZm9yIChpbnQzMl90IHUgPSA3Njc7IHUgPD0gY19saW1pdDsgKyt1KQogICB7CiAgICAgIGZvciAoaW50MzJfdCB2ID0gNzY3OyB2IDw9IGNfbGltaXQ7ICsrdikKICAgICAgewogICAgICAgICBpZiAoY29uZF8xKHUsIHYpICYmIGNvbmRfMih1LCB2KSAmJiBjb25kXzModSwgdikgJiYgY29uZF80KHUsIHYpICYmIGNvbmRfNSh1LCB2KSAmJgogICAgICAgICAgICAgY29uZF82KHUsIHYpICYmIGNvbmRfNyh1LCB2KSAmJiBjb25kXzgodSwgdikgJiYgY29uZF85KHUsIHYpICYmIGNvbmRfMTAodSwgdikpCiAgICAgICAgIHsKICAgICAgICAgICAgY291dCA8PCAiKCIgPDwgdSA8PCAiLCAiIDw8IHYgPDwgIikiIDw8IGVuZGw7CiAgICAgICAgICAgIGNvdW50Kys7CiAgICAgICAgIH0KICAgICAgfQogICB9CgogICBjb3V0IDw8IGNvdW50IDw8ICIgcGFpcnMiIDw8IGVuZGw7CgogICByZXR1cm4gMDsKfQ==