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 a[260];
double logg[10010];
double logsum[10010];
double uniform_prob(int P, int k) {
  k += P;
  if (k >= 0 && k <= 2 * P) return -logg[2 * P + 1];
  return -1.0E+18;
}
double poisson_prob(int P, int k) {
  k += P;
  if (k < 0) return -1.0E+18;
  return logg[P] * k - P - logsum[k];
}
double get_uniform(int P) {
  int i;
  double ans = 0.0;
  for ((i) = 0; (i) < (int)(250); (i)++) ans += uniform_prob(P, a[i]);
  return ans;
}
double get_poisson(int P) {
  int i;
  double ans = 0.0;
  for ((i) = 0; (i) < (int)(250); (i)++) ans += poisson_prob(P, a[i]);
  return ans;
}
void main2(void) {
  char type = '?';
  int P = -1;
  double best = -1.0E+18;
  int i;
  for (i = 1; i <= 1000; i++) {
    double tmp = get_uniform(i);
    if (tmp > best) {
      best = tmp;
      type = 'u';
      P = i;
    }
    tmp = get_poisson(i);
    if (tmp > best) {
      best = tmp;
      type = 'p';
      P = i;
    }
  }
  cout << ((type == 'p') ? "poisson" : "uniform") << endl;
}
int main(void) {
  int TC, tc, i;
  for ((i) = 0; (i) < (int)(10000); (i)++) logg[i] = log(i);
  for ((i) = 0; (i) < (int)(10000); (i)++)
    logsum[i + 1] = logsum[i] + log(i + 1);
  cin >> TC;
  for ((tc) = 0; (tc) < (int)(TC); (tc)++) {
    for ((i) = 0; (i) < (int)(250); (i)++) scanf("%d", &a[i]);
    main2();
  }
  return 0;
}