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;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int N = 250;
int x[N];
bool solvetype() {
  int mn = x[0];
  for (int i = (1); i < (N); ++i)
    if (x[i] < mn) mn = x[i];
  int mx = x[0];
  for (int i = (1); i < (N); ++i)
    if (x[i] > mx) mx = x[i];
  double bestunif = -1e200;
  for (int P = ((mx - mn + 1) / 2); P <= (1000); ++P) {
    double cur = N * log(1.0 / (2 * P + 1));
    if (cur > bestunif) bestunif = cur;
  }
  double bestpois = -1e200;
  vector<double> lfac(1);
  lfac[0] = log(1.0);
  double sum = 0;
  for (int i = (0); i < (N); ++i) sum += x[i];
  int avg = (int)floor(sum / N + .5);
  for (int c = (avg); c <= (avg); ++c)
    for (int P = (max(1, c - mn)); P <= (1000); ++P) {
      int z = c - P;
      double cur = 0;
      for (int i = (0); i < (N); ++i) {
        int y = x[i] - z;
        while (y >= ((int)(lfac).size()))
          lfac.push_back(lfac.back() + log(1.0 * ((int)(lfac).size())));
        long double now = y * log(1.0 * P) - lfac[y] - P;
        cur += now;
      }
      if (cur > bestpois) {
        bestpois = cur;
      }
    }
  return bestunif > bestpois;
}
void run() {
  for (int i = (0); i < (N); ++i) scanf("%d", &x[i]);
  printf("%s\n", solvetype() ? "uniform" : "poisson");
}
void test(bool have, bool want, int P) {
  if (have != want)
    printf("err (have=%s,want=%s,P=%d)\n", have ? "uniform" : "poisson",
           want ? "uniform" : "poisson", P);
}
void testunif() {
  int mod = rand() % 201 - 100;
  int P = rand() % (10 - 1 + 1) + 1;
  for (int i = (0); i < (N); ++i) x[i] = rand() % (2 * P + 1) + mod;
  test(solvetype(), true, P);
}
void testpoisson() {
  int mod = rand() % 201 - 100;
  int P = rand() % (10 - 1 + 1) + 1;
  double L = exp(-1.0 * P);
  for (int i = (0); i < (N); ++i) {
    int k = 0;
    double p = 1;
    do {
      ++k;
      double u = 1.0 * rand() / RAND_MAX;
      p *= u;
    } while (p > L);
    x[i] = k - 1 + mod;
  }
  test(solvetype(), false, P);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = (1); i <= (n); ++i) run();
  return 0;
}