#include <bits/stdc++.h>
const int INF = 0x3f3f3f3f;
const int MAXN = 200005;
using namespace std;
using ii = pair<int, int>;
using ll = long long int;
using vi = vector<ii>;
using graph = vector<vi>;
graph g;
int v[MAXN], ans[MAXN], sz[MAXN];
bool seen[MAXN];
int dfs(int u) {
  seen[u] = 1;
  sz[u] = v[u];
  for (auto w : g[u])
    if (!seen[w.first]) {
      dfs(w.first);
      if (w.second < 0)
        ans[-w.second] = -sz[w.first];
      else
        ans[w.second] = sz[w.first];
      sz[u] += sz[w.first];
    }
}
int main() {
  int n, m, k;
  scanf("%d", &n);
  g.assign(n + 1, vi());
  int res = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", v + i);
    res += v[i];
  }
  if (res) {
    puts("Impossible");
    return 0;
  }
  scanf("%d", &m);
  for (int i = 1, u, w; i <= m; ++i) {
    scanf("%d %d", &u, &w);
    g[u].emplace_back(w, i);
    g[w].emplace_back(u, -i);
  }
  puts("Possible");
  dfs(1);
  for (int i = 1; i <= m; ++i) {
    printf("%d\n", ans[i]);
  }
}
