#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, M = 3e5 + 5;
int n, m, i, j, k, x, y;
long long t, a[N], f[M];
int lst[N], e[M * 2][3], data[N];
int fa[N], b[N], dx[M], dy[M];
bool bz[N], bz2[M];
void link(int x, int y, int k) {
  e[++t][0] = lst[x], e[t][1] = y, e[t][2] = k, lst[x] = t;
}
void dg(int x) {
  int h = 0, t = 1;
  data[1] = x, bz[x] = 1;
  while (h < t) {
    x = data[++h];
    int i = lst[x];
    while (i) {
      int y = e[i][1];
      if (!bz[y]) bz[y] = 1, data[++t] = y, fa[y] = x, bz2[b[y] = e[i][2]] = 1;
      i = e[i][0];
    }
  }
}
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%I64d", &a[i]), a[i] = -a[i];
  scanf("%d", &m);
  for (i = 1; i <= m; i++)
    scanf("%d%d", &x, &y), link(dx[i] = x, dy[i] = y, i), link(y, x, i);
  t = 0;
  for (i = 1; i <= n; i++) t += a[i];
  if (t != 0) {
    printf("Impossible");
    return 0;
  }
  printf("Possible\n");
  dg(1);
  for (i = n; i >= 2; i--) x = data[i], y = fa[x], f[b[x]] = a[x], a[y] += a[x];
  for (i = 1; i <= m; i++)
    if (!bz2[i])
      printf("0\n");
    else {
      x = dx[i], y = dy[i];
      if (fa[y] == x) f[i] = -f[i];
      printf("%I64d\n", f[i]);
    }
}
