#include <bits/stdc++.h>
using namespace std;
const int maxn = 500010, inf = 1e9;
struct edge {
  int too, pos, pre;
} e[maxn << 1];
int n, m, tot, x, y;
int a[maxn], last[maxn], v[maxn], ans[maxn];
template <typename T>
inline void read(T &k) {
  int f = 1;
  k = 0;
  char c = getchar();
  while (c < '0' || c > '9') c == '-' && (f = -1), c = getchar();
  while (c <= '9' && c >= '0') k = k * 10 + c - '0', c = getchar();
  k *= f;
}
inline void add(int x, int y, int z) {
  e[++tot] = (edge){y, z, last[x]};
  last[x] = tot;
}
int dfs(int x) {
  v[x] = 1;
  for (int i = last[x], too; i; i = e[i].pre)
    if (!v[too = e[i].too]) {
      int tmp = dfs(too);
      ans[abs(e[i].pos)] = (e[i].pos > 0) ? tmp : -tmp;
      a[x] += tmp;
    }
  return a[x];
}
int main() {
  read(n);
  int sum = 0;
  for (int i = 1; i <= n; i++) read(a[i]), sum += a[i];
  if (sum) return puts("Impossible"), 0;
  read(m);
  for (int i = 1; i <= m; i++) read(x), read(y), add(x, y, i), add(y, x, -i);
  puts("Possible");
  dfs(1);
  for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
}
