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;
inline int readInt() {
  int n = 0, ch = getchar();
  bool flag = false;
  while (!isdigit(ch)) flag |= ch == '-', ch = getchar();
  while (isdigit(ch)) n = n * 10 + ch - '0', ch = getchar();
  return flag ? -n : n;
}
const int MAX_N = 250 + 3, MAX_VAL = 5000;
int n, a[MAX_N], cnt[MAX_VAL];
inline double E(int a[], int len = 250) {
  return accumulate(a, a + len, 0.0) / len;
}
inline double D(int a[], int len = 250) {
  double avg = E(a), s = 0;
  for (int i = 0; i < len; ++i) s += (a[i] - avg) * (a[i] - avg);
  s /= len;
  return sqrt(s);
}
inline double calc(int a[], int len) {
  double e = E(a, len), d = D(a, len);
  return d;
}
const double uni[] = {0,      82.375, 49.216, 35.004, 27.779, 22.002, 18.792,
                      16.332, 14.090, 12.643, 11.408, 10.626, 9.327,  8.613,
                      8.311,  7.727,  7.013,  6.734,  6.399,  6.002,  5.650};
int main() {
  int caseNum = readInt();
  while (caseNum--) {
    n = 250;
    for (int i = 0; i < 250; ++i) a[i] = readInt();
    int mn = *min_element(a, a + n), mx = *max_element(a, a + n);
    memset(cnt, 0, sizeof cnt);
    for (int i = 0; i < 250; ++i) cnt[a[i] - min(0, mn)]++;
    double d = D(cnt, mx - mn + 1);
    int t = max(abs(mx), abs(mn));
    if (t <= 10) {
      if (fabs((uni[max(abs(mx), abs(mn))] - d) / d) < 0.1) {
        puts("uniform");
      } else
        puts("poisson");
    } else {
      int len = max(1., (mx - mn + 1) * 0.15);
      int cnt1 = 0, cnt2 = 0;
      for (int i = 0; i < 250; ++i)
        if (a[i] <= mn + len) ++cnt1;
      for (int i = 0; i < 250; ++i)
        if (a[i] >= mx - len) ++cnt2;
      int cnt = (double)len * 2 * 250 / (mx - mn + 1) * 0.7;
      if (cnt1 + cnt2 <= cnt) {
        puts("poisson");
      } else {
        puts("uniform");
      }
    }
  }
  return 0;
}