#include <iostream>
#include <array>
#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;

using coef_t = array<int32_t, 9u>;

coef_t getCoef(int32_t n)
{
   coef_t coef;
   for (auto i = 0u; i < coef.max_size(); ++i)
   {
      coef[i] = n >> i;
   }
   return coef;
}

bool cond_1(const coef_t& a, const coef_t& b)  { return (-1    + a[8]) == (-b[3] + b[2]); }
bool cond_2(const coef_t& a, const coef_t& b)  { return ( a[8] - a[7]) == ( b[4] - b[3]); }
bool cond_3(const coef_t& a, const coef_t& b)  { return (-a[7] + a[6]) == (-b[5] + b[4]); }
bool cond_4(const coef_t& a, const coef_t& b)  { return ( a[6] - a[5]) == ( 1    - b[8]); }
bool cond_5(const coef_t& a, const coef_t& b)  { return (-a[5] + a[4]) == ( 1    - b[0]); }
bool cond_6(const coef_t& a, const coef_t& b)  { return ( a[4] - a[3]) == ( b[8] + b[7]); }
bool cond_7(const coef_t& a, const coef_t& b)  { return (-a[3] + a[2]) == (-b[7] + b[6]); }
bool cond_8(const coef_t& a, const coef_t& b)  { return ( a[2] - a[1]) == (-b[1] + b[0]); }
bool cond_9(const coef_t& a, const coef_t& b)  { return (-a[1] + a[0]) == ( b[2] - b[1]); }
bool cond_10(const coef_t& a, const coef_t& b) { return (-a[0] + 1)    == ( b[6] - b[5]); }

int main()
{
   size_t count = 0;
   for (int32_t u = 767; u <= c_limit; ++u)
   {
      const coef_t a = getCoef(u);
      for (int32_t v = 767; v <= c_limit; ++v)
      {
         const coef_t b = getCoef(v);

         if (cond_1(a, b) && cond_2(a, b) && cond_3(a, b) && cond_4(a, b) && cond_5(a, b) &&
             cond_6(a, b) && cond_7(a, b) && cond_8(a, b) && cond_9(a, b) && cond_10(a, b))
         {
            cout << "(" << u << ", " << v << ")" << endl;
            count++;
         }
      }
   }

   cout << count << " pairs" << endl;

   return 0;
}