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;
static bool debug = false;
template <typename T, typename Q, typename S>
bool Bounded(const T &x, const Q &a, const S &b) {
  return a <= x && x <= b;
}
const long double pi = 4 * atan(long double(1.0));
const long double Inf = numeric_limits<long double>::infinity();
long double isapprox(
    long double x, long double y,
    long double rtol = sqrt(numeric_limits<long double>::epsilon()),
    long double atol = long double(0.0), bool nans = false) {
  return x == y || (nans && isnan(x) && isnan(y)) ||
         (isfinite(x) && isfinite(y) &&
          abs(x - y) <= atol + rtol * max(abs(x), abs(y)));
}
template <typename T>
int sz(const T &x) {
  return (int)x.size();
}
template <typename T, typename Q>
bool mem(const T &s, const Q &x) {
  return s.find(x) != s.end();
}
template <typename T>
void push(vector<T> &c, const T &e) {
  c.push_back(e);
}
template <typename T>
void push(queue<T> &c, const T &e) {
  c.push(e);
}
template <typename T>
void push(set<T> &c, const T &e) {
  c.insert(e);
}
template <typename T>
T pop(vector<T> &v) {
  assert(!v.empty());
  T u = v.back();
  v.pop_back();
  return u;
}
template <typename T>
T pop(queue<T> &v) {
  assert(!v.empty());
  T u = v.front();
  v.pop();
  return u;
}
template <typename T, typename... Args>
auto emplace(vector<T> &c, Args &&...args)
    -> decltype(c.emplace_back(args...)) {
  c.emplace_back(args...);
}
template <typename T, typename... Args>
auto emplace(queue<T> &c, Args &&...args) -> decltype(c.emplace(args...)) {
  c.emplace(args...);
}
template <typename T, typename... Args>
auto emplace(set<T> &c, Args &&...args) -> decltype(c.emplace(args...)) {
  c.emplace(args...);
}
template <typename T>
void umin(T &x, const T &y) {
  x = min(x, y);
}
template <typename T>
void umax(T &x, const T &y) {
  x = max(x, y);
}
template <typename T>
int sign(const T &x) {
  return x == 0 ? 0 : x > 0 ? 1 : -1;
}
template <typename T>
T square(const T &x) {
  return x * x;
}
template <typename S, typename T>
istream &operator>>(istream &in, pair<S, T> &p) {
  return in >> p.first >> p.second;
}
template <typename T>
T read() {
  T x;
  cin >> x;
  return x;
}
template <typename T, typename I = typename T::iterator>
void read(T &cnt) {
  for (auto &x : cnt) cin >> x;
}
template <typename S, typename T>
ostream &operator<<(ostream &out, const pair<S, T> &p) {
  return out << "{" << p.first << ", " << p.second << "}";
}
template <typename T>
struct show_container {
  const T &container;
  show_container(const T &container_) : container(container_) {}
};
template <typename T>
ostream &operator<<(ostream &o, const show_container<T> &thing) {
  bool first = true;
  o << "{";
  for (const auto &x : thing.container) {
    if (!first) o << ", ";
    first = false;
    o << x;
  }
  o << "}";
  return o;
}
template <typename T>
show_container<T> show(const T &container) {
  return show_container<T>(container);
}
struct dout_ {
} dout;
template <typename T>
dout_ &operator<<(dout_ &out, const T &thing) {
  return out;
}
dout_ &operator<<(dout_ &out, ostream &(*thing)(ostream &)) { return out; }
struct outboth {
  ostream &a;
  ostream &b;
  outboth(ostream &a_, ostream &b_) : a(a_), b(b_) {}
};
template <typename T>
outboth &operator<<(outboth &both, const T &thing) {
  both.a << thing;
  both.b << thing;
  return both;
}
outboth &operator<<(outboth &both, ostream &(*thing)(ostream &)) {
  both.a << thing;
  both.b << thing;
  return both;
}
vector<long double> logFactorial_memo;
long double logFactorial(int x) {
  if (x >= sz(logFactorial_memo)) return lgamma(long double(x + 1));
  return logFactorial_memo[x];
}
long double logpPoisson(const vector<int> &X, int P) {
  long double ans = 0;
  for (int x : X) ans += x * log(long double(P)) - P - logFactorial(x);
  return ans;
}
long double logpUniform(const vector<int> &X, int P) {
  for (int x : X)
    if (!Bounded(x, 0, 2 * P)) return -Inf;
  return -sz(X) * log(2 * P + long double(1));
}
void solve(ostream &rout) {
  logFactorial_memo.resize(2000);
  for (int i = 0; i < sz(logFactorial_memo); ++i)
    logFactorial_memo[i] = lgamma(long double(i + 1));
  int V;
  cin >> V;
  if (!cin) return;
  const int N = 250;
  for (int v = 0; v < int(V); ++v) {
    vector<int> X(N);
    read(X);
    int xmin = *min_element(X.begin(), X.end()),
        xmax = *max_element(X.begin(), X.end());
    long double sumX = 0;
    for (int x : X) sumX += x;
    long double pU = -N * log(long double(2 * max(abs(xmin), abs(xmax)) + 1));
    long double pP = -Inf;
    for (int P = 1; P <= 1000; ++P) {
      if (xmin + P < 0) continue;
      long double p = -N * P + (sumX + N * P) * log(long double(P));
      for (int x : X) p -= logFactorial(x + P);
      umax(pP, p);
    }
    rout << (pP > pU ? "poisson" : "uniform") << endl;
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);
  solve(cout);
  return 0;
}