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 m = 250;
int n, a[m];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int i = 0; i < m; i++) scanf("%d", a + i);
    double var = 0.0;
    for (int i = 0; i < m; i++) {
      var += a[i] * a[i];
    }
    var /= (m - 1);
    double abs = 0.0;
    for (int i = 0; i < m; i++) {
      abs += std::abs(a[i]);
    }
    abs /= m - 1;
    int outside = 0;
    int k =
        (std::abs(*std::min_element(a, a + m)) + *std::max_element(a, a + m)) /
        4;
    for (int i = 0; i < m; i++) {
      if (std::abs(a[i]) > k) {
        outside++;
      }
    }
    int min = *std::min_element(a, a + m);
    int max = *std::max_element(a, a + m);
    bool pois;
    if (min >= -2) {
      pois = (-min != max);
    } else {
      pois = outside < 90;
    }
    printf("%s\n", pois ? "poisson" : "uniform");
  }
}