Problem: Your task is the exact same as for the easy version. But this time, the marmots subtract the village's population P from their random number before responding to Heidi's request.

Also, there are now villages with as few as a single inhabitant, meaning that <image>.

Can you help Heidi find out whether a village follows a Poisson or a uniform distribution?

Input

Same as for the easy and medium versions. But remember that now 1 ≤ P ≤ 1000 and that the marmots may provide positive as well as negative integers.

Output

Output one line per village, in the same order as provided in the input. The village's line shall state poisson if the village's distribution is of the Poisson type, and uniform if the answers came from a uniform distribution.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int cnt[2010];
long double expected[2][1002][2010];
void init() {
  for (int T = 1; T <= 1000; T++) {
    for (int j = 0; j <= 2 * T; j++)
      expected[0][T][j - T + 1002] = (long double)1 / (2 * T + 1);
    long double cv = exp((long double)-T);
    for (int j = 0; j <= 2 * T; j++) {
      expected[1][T][j - T + 1002] = cv;
      cv = cv * T / (j + 1);
    }
  }
}
inline long double check(long double* expect) {
  long double ret = 0;
  for (int i = 0; i <= 2000; i++) {
    if (!cnt[i]) continue;
    if (expect[i] == 0) return -1e15;
    ret += cnt[i] * log(expect[i]);
  }
  return ret;
}
void solve() {
  memset(cnt, 0, sizeof(cnt));
  bool precheck = 0;
  for (int i = 0, ti; i < 250; i++) {
    scanf("%d", &ti);
    if (ti > 1000 || ti < -1000)
      precheck = 1;
    else
      cnt[ti + 1002]++;
  }
  if (precheck)
    puts("poisson");
  else {
    pair<long double, int> mn = make_pair(-1e15, 0);
    for (int i = 1; i <= 1000; i++) {
      mn = max(mn, make_pair(check(expected[0][i]), 0));
      mn = max(mn, make_pair(check(expected[1][i]), 1));
    }
    if (mn.second == 0)
      puts("uniform");
    else
      puts("poisson");
  }
}
int T;
int main() {
  scanf("%d", &T);
  init();
  while (T--) solve();
  return 0;
}