#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
vector<int> g[maxn];
int s[maxn];
int par[maxn], _rank[maxn];
void init(int n) {
  for (int i = 1; i <= n; i++) {
    par[i] = i;
    _rank[i] = 0;
  }
}
int find(int x) {
  if (par[x] == x) return x;
  return par[x] = find(par[x]);
}
inline void unite(int x, int y) {
  x = find(x), y = find(y);
  if (x == y) return;
  if (_rank[x] < _rank[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (_rank[x] == _rank[y]) _rank[x]++;
  }
}
inline bool same(int x, int y) { return find(x) == find(y); }
bool used[maxn];
pair<int, int> edge[maxn];
int dep[maxn], sum[maxn];
void dfs(int u, int fa) {
  sum[u] = s[u];
  for (int i = 0; i < (int)g[u].size(); i++) {
    int v = g[u][i];
    if (v == fa) continue;
    dep[v] = dep[u] + 1;
    dfs(v, u);
    sum[u] += sum[v];
  }
}
int main() {
  int n, tot_s = 0, x, y;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", s + i);
    tot_s += s[i];
  }
  if (tot_s != 0) {
    puts("Impossible");
  } else {
    init(n);
    int m;
    scanf("%d", &m);
    for (int i = 1; i <= m; i++) {
      scanf("%d%d", &x, &y);
      edge[i] = pair<int, int>(x, y);
      if (!same(x, y)) {
        unite(x, y);
        used[i] = true;
        g[x].push_back(y);
        g[y].push_back(x);
      }
    }
    dfs(1, -1);
    puts("Possible");
    for (int i = 1; i <= m; i++) {
      if (used[i]) {
        int x = edge[i].first, y = edge[i].second;
        if (dep[x] < dep[y]) {
          printf("%d\n", sum[y]);
        } else {
          printf("%d\n", -sum[x]);
        }
      } else {
        puts("0");
      }
    }
  }
  return 0;
}
