#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
const int maxn = 2e5 + 100, INF = 0x3f3f3f3f;
int n, m, k;
int val[maxn];
int First[maxn], cnt = 0, d[maxn];
long long ans[maxn];
bool vis[maxn], done[maxn], finished[maxn * 2];
struct Node {
  int to, id, op;
};
vector<Node> ac[maxn];
int record[maxn], Real[maxn * 2];
void add(int from, int v, int id, int op) {
  ac[from].push_back(Node{v, id, op});
}
void init() {
  memset(First, -1, sizeof(First));
  cnt = 0;
  memset(vis, 0, sizeof(vis));
  memset(done, 0, sizeof(done));
}
int dfs(int u) {
  vis[u] = 1;
  for (auto e : ac[u]) {
    int to = e.to, id = e.id, op = e.op;
    if (vis[to] || finished[id]) continue;
    int vv = dfs(to) * op;
    Real[id] = vv;
    val[u] += Real[id] * op;
  }
  return val[u];
}
int main() {
  init();
  scanf("%d", &n);
  long long sum = 0;
  for (int i = 1; i <= n; i++) scanf("%d", &val[i]), sum += val[i];
  scanf("%d", &m);
  int cnt = 0;
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    add(a, b, cnt++, 1);
    add(b, a, cnt++, -1);
  }
  if (sum != 0) {
    puts("Impossible");
    return 0;
  }
  dfs(1);
  puts("Possible");
  for (int i = 0; i < cnt; i += 2) {
    if (Real[i])
      printf("%d\n", Real[i]);
    else
      printf("%d\n", Real[i + 1]);
  }
  return 0;
}
