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;
double fac[200005], ln[200005];
inline double Poi(int x, int P) {
  x += P;
  return x * ln[P] - P - fac[x];
}
inline double Uni(int x, int P) {
  x += P;
  if (x < 0 || x > 2 * P) return -1e20;
  return -ln[2 * P + 1];
}
const int N = 255;
int T;
int a[N];
int main() {
  int T;
  scanf("%d", &(T));
  fac[0] = 0;
  for (int i = 1; i <= 200000; i++) fac[i] = fac[i - 1] + (ln[i] = log(i));
  while (T--) {
    for (int i = 1; i <= 250; i++) scanf("%d", &(a[i]));
    int t = -1, P = -1;
    double maxv = -1e20;
    for (int p = 1; p <= 1000; p++) {
      double ret = 0;
      for (int i = 1; i <= 250; i++) ret += Poi(a[i], p);
      if (ret > maxv) maxv = ret, t = 0, P = p;
      ret = 0;
      for (int i = 1; i <= 250; i++) ret += Uni(a[i], p);
      if (ret > maxv) maxv = ret, t = 1, P = p;
    }
    if (t == 0)
      printf("poisson\n");
    else
      printf("uniform\n");
  }
  return 0;
}