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 N = 10005;
int a[N];
int main() {
  int T;
  srand(time(0));
  scanf("%d", &(T));
  while (T--) {
    double ex = 0;
    int minv = 1 << 30, maxv = -1 << 30;
    int n = 250;
    for (int i = 1; i <= 250; i++) {
      if (!(~scanf("%d", &(a[i])))) {
        n = i - 1;
        break;
      }
      minv = min(minv, a[i]);
      maxv = max(maxv, a[i]);
    }
    int x = (abs(minv) + abs(maxv)) / 4;
    int c0 = 0, c1 = 0;
    for (int i = 1; i <= n; i++)
      if (abs(a[i]) <= x)
        c0++;
      else
        c1++;
    if (minv >= -10) {
      if (abs(maxv) > abs(minv))
        printf("poisson\n");
      else {
        if (c1 == 0 || c0 / c1 > 1.3)
          printf("poisson\n");
        else
          printf("uniform\n");
      }
      continue;
    }
    if (c1 == 0 || c0 / c1 > 1.3)
      printf("poisson\n");
    else
      printf("uniform\n");
  }
  return 0;
}