#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
int fa[MAXN], n, m, U[MAXN], V[MAXN];
long long s[MAXN], f[MAXN];
int fin(int u) { return fa[u] == u ? u : fa[u] = fin(fa[u]); }
vector<pair<int, int> > G[MAXN];
void dfs(int u, int fa) {
  for (auto x : G[u]) {
    int v = x.first, i = x.second;
    if (v == fa) continue;
    dfs(v, u);
    if (U[i] == u)
      f[i] = s[v];
    else
      f[i] = -s[v];
    s[u] += s[v];
  }
}
int main() {
  cin >> n;
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &s[i]);
    fa[i] = i;
    sum += s[i];
  }
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    U[i] = u;
    V[i] = v;
    int x = fin(u), y = fin(v);
    if (x != y) {
      G[u].push_back(make_pair(v, i));
      G[v].push_back(make_pair(u, i));
      fa[x] = y;
    }
  }
  if (sum != 0) {
    puts("Impossible");
    return 0;
  }
  dfs(1, 0);
  puts("Possible");
  for (int i = 1; i <= m; i++) printf("%lld\n", f[i]);
}
