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;
const int P = 1000;
const int M = 10 * P;
const int N = 250;
const long double inf = 1e18;
int a[N];
long double lg[M];
long double ls[M];
long double pois(int k, int p) {
  k += p;
  if (k < 0) return -inf;
  if (k == 0) return -p;
  return k * lg[p] - p - ls[k];
}
long double unif(int k, int p) {
  k += p;
  if (k < 0 or k > 2 * p) return -inf;
  return -lg[2 * p + 1];
}
long double sum_pois(int p) {
  long double res = 0;
  for (int i = 0; i < N; ++i) res += pois(a[i], p);
  return res;
}
long double sum_unif(int p) {
  long double res = 0;
  for (int i = 0; i < N; ++i) res += unif(a[i], p);
  return res;
}
int main() {
  cin.sync_with_stdio(0);
  cout.sync_with_stdio(0);
  ls[1] = lg[1] = 0;
  for (int i = 2; i < M; ++i) {
    lg[i] = logl(i);
    ls[i] = ls[i - 1] + lg[i];
  }
  int t;
  cin >> t;
  while (t--) {
    for (int i = 0; i < N; ++i) {
      cin >> a[i];
    }
    long double p_unif = -inf, p_pois = -inf, tmp;
    for (int p = 1; p <= 1000; ++p) {
      tmp = sum_pois(p);
      if (p_pois < tmp) {
        p_pois = tmp;
      }
      tmp = sum_unif(p);
      if (p_unif < tmp) {
        p_unif = tmp;
      }
    }
    if (p_pois > p_unif)
      cout << "poisson\n";
    else
      cout << "uniform\n";
  }
  return 0;
}