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 P;
int g1() {
  double p = rand() / 32767.0, s = 0, g = 1;
  for (int k = 0;; k++) {
    if (k) g *= k;
    double c = pow(P, k) * exp(-P) / g;
    s += c;
    if (p <= s) return k;
  }
}
int g2() {
  double p = rand() / 32767.0, s = 0;
  for (int k = 0; k <= P + P; k++) {
    s += 1.0 / (2 * P + 1);
    if (p <= s) return k;
  }
  return P + P;
}
int main() {
  int v;
  scanf("%d", &v);
  while (v--) {
    vector<int> vs;
    for (int i = 0; i < 250; i++) {
      int x;
      scanf("%d", &x);
      vs.push_back(x);
    }
    double avr = 0, ss = 0, s1 = 0, s2 = 0;
    for (int i = 0; i < 250; i++) avr += (double)vs[i];
    avr /= 250;
    int mx = 0;
    for (int i = 0; i < 250; i++)
      ss += (vs[i] - avr) * (vs[i] - avr), mx = max(mx, vs[i]), s1 += vs[i],
                                           s2 += vs[i] * vs[i];
    double s0 = sqrt((ss - s1 * s1 / 250) / 250);
    ss /= avr;
    if (mx < s0 * 2)
      puts("uniform");
    else
      puts("poisson");
  }
}