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>
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
int IT_MAX = 1 << 19;
const long long MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1E-11;
const int MX = 100005;
void make(int P, int A[]) {
  for (int i = 0; i < 250; i++) {
    A[i] = rand() % (2 * P + 1) - P;
  }
}
double X[51][255];
void poisson(int P, int A[], int t) {
  double pos[10001] = {};
  double r = 1;
  for (int k = 0; k <= 10000; k++) {
    if (k) r = r * k;
    pos[k] = exp(-P) * pow(P, k) / r;
  }
  if (P <= 50 && t)
    for (int k = 0; k <= 100; k++) X[P][k] = pos[k];
  for (int i = 0; i < 250; i++) {
    double pp = (double)rand() / RAND_MAX;
    int f = -1;
    for (int j = 0; j <= 10000; j++) {
      if (pp <= pos[j]) {
        f = j;
        break;
      } else
        pp -= pos[j];
    }
    A[i] = f - P;
  }
}
double get(int P, int x) {
  x += P;
  if (x < 0) return 0;
  return X[P][x];
}
void Do(int x, int y) {
  int A[255] = {};
  for (int i = 0; i < 250; i++) scanf("%d", A + i);
  int t = *max_element(A, A + 250) - *min_element(A, A + 250);
  if (t == 2) {
    puts("uniform");
    return;
  }
  int temp[10010] = {};
  int *B = temp + 5050;
  for (int i = 0; i < 250; i++) B[A[i]]++;
  if (t <= 20) {
    double xx[11] = {};
    if (t & 1) ++t;
    int tt = t / 2;
    for (int i = -tt; i <= tt; i++)
      xx[0] += (250.0 / (t + 1) - B[i]) * (250.0 / (t + 1) - B[i]);
    for (int P = 1; P <= 15; P++) {
      double rr = 0;
      for (int i = -20; i <= 20; i++)
        rr += (B[i] - get(P, i)) * (B[i] - get(P, i));
      xx[P] = rr;
    }
    int a = (int)(min_element(xx, xx + 16) - xx);
    if (a != 0)
      puts("poisson");
    else
      puts("uniform");
    return;
  }
  int a = 0, b = B[0];
  while (1) {
    if (b >= 125) break;
    ++a;
    b += B[a] + B[-a];
  }
  double C = 2 * a / (double)t;
  if (C < 0.35)
    puts("poisson");
  else
    puts("uniform");
}
int main() {
  for (int P = 1; P <= 35; P++) {
    int temp[300] = {};
    poisson(P, temp, 1);
    for (int i = 0; i <= 100; i++) X[P][i] *= 250;
  }
  int V;
  V = 1000;
  scanf("%d", &V);
  int x, y;
  while (V--) {
    Do(x, y);
  }
  return 0;
}