#include <bits/stdc++.h>
using namespace std;
int n, m, sum, s[200005], f[200005], g[200005], flag[200005], k = 1, la[200005],
                                                              ff[200005 * 2];
struct node {
  int a, b;
} e[200005 * 2];
void add(int a, int b) {
  e[++k] = (node){a, b};
  ff[k] = la[a];
  la[a] = k;
  e[++k] = (node){b, a};
  ff[k] = la[b];
  la[b] = k;
}
void dfs(int x) {
  flag[x] = 1;
  g[x] = s[x];
  for (int a = la[x]; a; a = ff[a]) {
    if (flag[e[a].b]) continue;
    dfs(e[a].b);
    g[x] += g[e[a].b];
    if (a & 1)
      f[a >> 1] = -g[e[a].b];
    else
      f[a >> 1] = g[e[a].b];
  }
}
int main() {
  int a, b;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &s[i]), sum += s[i];
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) scanf("%d%d", &a, &b), add(a, b);
  if (sum) {
    printf("Impossible\n");
    return 0;
  }
  for (int i = 1; i <= n; i++)
    if (!flag[i]) dfs(i);
  printf("Possible\n");
  for (int i = 1; i <= m; i++) printf("%d\n", f[i]);
  return 0;
}
