#include <bits/stdc++.h>
using namespace std;
void err() {
  cout << "shit" << endl;
  exit(1);
}
const int maxn = 2e5 + 10;
int s[maxn];
vector<pair<int, int> > adj[maxn];
int in_edge[maxn];
int ans[maxn];
int fa[maxn];
int findset(int x) { return fa[x] == x ? x : fa[x] = findset(fa[x]); }
int sum[maxn];
bool vis[maxn];
void dfs(int u) {
  sum[u] = s[u];
  vis[u] = true;
  int size = adj[u].size();
  for (int i = 0; i < size; i++) {
    int v = adj[u][i].first;
    if (vis[v]) continue;
    in_edge[v] = adj[u][i].second;
    dfs(v);
    sum[u] += sum[v];
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> s[i];
  for (int i = 0; i <= n; i++) fa[i] = i;
  int m;
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    int fu = findset(u), fv = findset(v);
    if (fu != fv) {
      fa[fv] = fu;
      adj[u].push_back(make_pair(v, i));
      adj[v].push_back(make_pair(u, -i));
    } else {
      ans[i] = 0;
    }
  }
  memset(vis, false, sizeof(vis));
  dfs(1);
  if (sum[1] != 0) {
    cout << "Impossible" << '\n';
    return 0;
  }
  cout << "Possible" << '\n';
  for (int i = 2; i <= n; i++) {
    int id = in_edge[i];
    if (id > 0)
      ans[id] = sum[i];
    else
      ans[-id] = -sum[i];
  }
  for (int i = 1; i <= m; i++) cout << ans[i] << '\n';
  return 0;
}
