#include <bits/stdc++.h>

using namespace std;

void readInt(int &x, int l, int r) {
  scanf("%d", &x);

  assert(l <= x && x <= r);
}

int sum(int n) {
  return n * (n + 1) / 2;
}

void solve() {
  int d, n; 

  readInt(d, 1, 4);
  readInt(n, 1, 4);

  for (int i = 0; i < d; i++) {
    n = sum(n);
  }

  printf("%d\n", n);
}

int main() {
  int cases; readInt(cases, 1, 20);

  for (int i = 0; i < cases; i++) {
    solve();
  }

  return 0;
}