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>
const int K = 1000, N = 250;
inline long long sqr(int x) { return (long long)x * x; }
long long solve(int a[], int b[]) {
  long long res = 0;
  for (int i = 0; i < N; ++i) res += sqr(a[i] - b[i]);
  return res;
}
int a[K + 1][N], b[K + 1][N], c[N];
void init() {
  std::random_device rd;
  std::mt19937 gen(rd());
  for (int i = 1; i <= K; ++i) {
    std::poisson_distribution<> d(i);
    for (int j = 0; j < N; ++j) a[i][j] = d(gen) - i;
    std::uniform_int_distribution<> u(0, 2 * i);
    for (int j = 0; j < N; ++j) b[i][j] = u(gen) - i;
    std::sort(a[i], a[i] + N);
    std::sort(b[i], b[i] + N);
  }
}
int main() {
  init();
  int tcase;
  for (scanf("%d", &tcase); tcase--;) {
    for (int i = 0; i < N; ++i) scanf("%d", &c[i]);
    std::sort(c, c + N);
    std::pair<long long, int> p, q;
    p.first = q.first = 1LL << 62;
    for (int i = 1; i <= K; ++i) p = std::min(p, {solve(a[i], c), i});
    for (int i = 1; i <= K; ++i) q = std::min(q, {solve(b[i], c), i});
    puts(p < q ? "poisson" : "uniform");
  }
  return 0;
}