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 t;
int vis[10001];
double Calc_Uniform(int l, int r) {
  memset(vis, 0, sizeof(vis));
  double sum = 0;
  for (int i = 1; i <= 250; i++) {
    int k = rand() % (r - l + 1) + l;
    vis[k]++;
    sum += k;
  }
  sum /= 250;
  double ans = 0;
  for (int i = l; i <= r; i++) ans += (sum - i) * (sum - i) * vis[i];
  return ans;
}
int main() {
  srand(2333);
  scanf("%d", &t);
  while (t--) {
    memset(vis, 0, sizeof(vis));
    int max0 = 0, min0 = 1e9;
    double xx = 0;
    for (int i = 1; i <= 250; i++) {
      int x;
      scanf("%d", &x);
      x += 1000;
      vis[x]++;
      max0 = max(max0, x);
      min0 = min(min0, x);
      xx += x;
    }
    xx /= 250;
    double ans1 = 0;
    for (int i = min0; i <= max0; i++) ans1 += (xx - i) * (xx - i) * vis[i];
    double ans2 = 0;
    for (int i = 1; i <= 500; i++) {
      double now = Calc_Uniform(min0, max0);
      ans2 += now;
    }
    ans2 /= 500;
    if (ans1 > ans2 * 0.7) {
      printf("uniform\n");
      continue;
    }
    printf("poisson\n");
  }
  return 0;
}