#include <bits/stdc++.h>
int x, y, u, v, d = 1, a, b;
int main() {
  for (scanf("%d%d", &a, &b); a; b /= 4, d *= 2, --a) {
    if (b % 4 == 0)
      u = y, v = x;
    else if (b % 4 == 1)
      u = x, v = y + d;
    else if (b % 4 == 2)
      u = x + d, v = y + d;
    else
      u = 2 * d - y - 1, v = d - x - 1;
    x = u, y = v;
  }
  printf("%d %d\n", x, y);
  return 0;
}
