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 double eps = 1e-10;
const int MOD = 1000000007;
int i, j, k, m, n, l;
long long ans, s1, s2;
int a[1000001], b[1000001];
long long d[2500][2500];
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
void what() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = 0; i < n + 2; i++)
    for (int j = 0; j < n + 2; j++) d[i][j] = 1e18;
  ans = 1e18;
  for (int i = n; i >= 1; i--) {
    for (int j = 1; j <= k; j++) {
      if (j == 1) {
        d[i][j] = a[i] + b[i];
      }
      d[i][j] = min(d[i][j], d[i + 1][j - 1] + a[i] + b[i]);
      d[i][j] = min(d[i][j], d[i + 1][j] + a[i] - a[i + 1]);
      if (j == k) ans = min(ans, d[i][j]);
    }
  }
  cout << ans << endl;
}
vector<int> GetPois(int P) {
  vector<double> ps;
  double s = -P;
  for (int k = 0; k < 2000; k++) {
    if (k > 1) s -= log(1.0 * k);
    double p = exp(s);
    ps.push_back(p);
    s += log(1.0 * P);
  }
  vector<int> ret;
  for (int i = 0; i < 250; i++) {
    double dp = (rand() * 1.0 + 1.0) / (1LL * RAND_MAX + 1);
    for (int k = 0; k < 2000; k++) {
      dp -= ps[k];
      if (dp < 0) {
        ret.push_back(k - P);
        break;
      }
    }
  }
  return ret;
}
vector<int> GetUni(int P) {
  vector<int> ret;
  for (int i = 0; i < 250; i++) {
    ret.push_back(rand() % (2 * P + 1) - P);
  }
  return ret;
}
double sumfuck[5000];
void prep() {
  sumfuck[0] = 0.0;
  for (int i = 1; i <= 2000; i++) sumfuck[i] = sumfuck[i - 1] + log(1.0 * i);
}
double Est(vector<int>& v, int P) {
  double ret = 0;
  double logp = log(P);
  for (int x : v) {
    x += P;
    if (x < 0) return -1e10;
    if (x > 2000) return -1e10;
    ret += (-P - sumfuck[x]) + x * logp;
  }
  return ret;
}
void solve(vector<int> v, bool check = false, bool pois = false) {
  double best = -1e50;
  int bestP = -1;
  for (int P = 2; P <= 1000; P++) {
    double p = Est(v, P);
    if (p > best) {
      best = p;
      bestP = P;
    }
  }
  int U = -10000, L = 10000;
  for (int x : v) U = max(U, x);
  for (int x : v) L = min(L, x);
  double P = (U - L + 1) / 2;
  double pp = 0.0;
  for (int x : v) pp += log(1.0 / (2 * P + 1));
  vector<int> freq(U - L + 1, 0);
  for (int x : v) freq[x - L]++;
  if (best > pp && bestP == 2 && L + U == 0) {
    double s = 0.0;
    for (int z = -P; z <= P; z++) {
      s += freq[z + P] * abs(z);
    }
    s /= (2 * P + 1);
    if (s > 47) best = -1e100;
  }
  if (best > pp) {
    if (!pois && check) {
      for (int u = 0; u < ((int)freq.size()); u++) cout << freq[u] << " ";
      cout << endl;
      cerr << L << "  " << U << endl;
      throw 12;
    }
    cout << "poisson" << endl;
  } else {
    if (pois && check) {
      for (int u = 0; u < ((int)freq.size()); u++) cout << freq[u] << " ";
      cout << endl;
      cerr << L << "  " << U << endl;
      throw 12;
    }
    cout << "uniform" << endl;
  }
}
int main() {
  prep();
  if (1) {
    cin >> n;
    for (int i = 0; i < n; i++) {
      vector<int> v;
      for (int fuck = 0; fuck < 250; fuck++) {
        cin >> j;
        v.push_back(j);
      }
      solve(v);
    }
    return 0;
  }
  for (int k = 0; k < 100000; k++) {
    for (int P = 1; P <= 1; P++) solve(GetUni(P), 1, 0);
    for (int P = 1; P <= 1; P++) solve(GetPois(P), 1, 1);
  }
  return 0;
}