#include <bits/stdc++.h>
using namespace std;
int n, m, s[401000], a[401000], vis[401000], answ[401000];
vector<pair<int, int> > edge[401000];
int dfs(int u, int f) {
  vis[u] = 1;
  for (auto v : edge[u])
    if (!vis[v.first]) {
      int d = dfs(v.first, u);
      answ[abs(v.second)] = v.second > 0 ? d : -d;
      s[u] += d;
    }
  return s[u];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &s[i]), s[0] += s[i];
  if (s[0]) return puts("Impossible"), 0;
  scanf("%d", &m);
  for (int i = 1, u, v; i <= m; ++i)
    scanf("%d%d", &u, &v), edge[u].push_back(pair<int, int>(v, i)),
        edge[v].push_back(pair<int, int>(u, -i));
  puts("Possible");
  dfs(1, 0);
  for (int i = 1; i <= m; ++i) printf("%d\n", answ[i]);
}
