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 comment(linker, "/STACK:102400000,102400000")
using namespace std;
template <class T, class U>
inline void Max(T &a, U b) {
  if (a < b) a = b;
}
template <class T, class U>
inline void Min(T &a, U b) {
  if (a > b) a = b;
}
inline void add(int &a, int b) {
  a += b;
  while (a >= 1000000007) a -= 1000000007;
}
int pow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = ans * (long long)a % 1000000007;
    a = (long long)a * a % 1000000007;
    b >>= 1;
  }
  return ans;
}
int a[300];
double logsum[10010], INF = 1e18, logg[10010];
double poisson_prob(int p, int k) {
  k += p;
  if (k < 0) return -INF;
  return -p + k * logg[p] - logsum[k];
}
double uniform_prob(int p, int k) {
  k += p;
  if (k < 0 || k > 2 * p) return -INF;
  return -logg[2 * p + 1];
}
double poisson(int p) {
  double ans = 0;
  for (int i = 0; i < 250; i++) {
    ans += poisson_prob(p, a[i]);
  }
  return ans;
}
double uniform(int p) {
  double ans = 0;
  for (int i = 0; i < 250; i++) {
    ans += uniform_prob(p, a[i]);
  }
  return ans;
}
double sqr(double first) { return first * first; }
int main() {
  int T, i = 0, j, k, ca = 0, m = 250, K, n;
  logsum[1] = 0;
  for (int i = 2; i < 10010; i++)
    logg[i] = log(i), logsum[i] = logsum[i - 1] + logg[i];
  scanf("%d", &T);
  while (T--) {
    for (int i = 0; i < m; i++) scanf("%d", &a[i]);
    double ans = -INF;
    for (int p = 1; p < 1001; p++) {
      double a = poisson(p);
      if (ans < a) ans = a, K = 1;
      a = uniform(p);
      if (ans < a) ans = a, K = 0;
    }
    puts(K ? "poisson" : "uniform");
  }
  return 0;
}