#include <bits/stdc++.h>
using namespace std;
int n, m, sum;
int s[200010];
vector<pair<int, int> > G[200010];
int fa[200010];
int vis[200010];
int ans[200010];
void dfs(int x, int fa, int id) {
  vis[x] = 1;
  for (int i = 0; i < G[x].size(); i++) {
    int to = G[x][i].first;
    int id = G[x][i].second;
    if (vis[to] == 0) dfs(to, x, id);
  }
  if (s[x] != 0) {
    if (id > 0)
      ans[id] -= s[x];
    else
      ans[-id] += s[x];
    s[fa] += s[x];
    s[x] = 0;
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> s[i], sum += s[i], s[i] = -s[i];
  if (sum) return puts("Impossible"), 0;
  puts("Possible");
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    G[x].push_back(make_pair(y, i));
    G[y].push_back(make_pair(x, -i));
  }
  dfs(1, 0, 0);
  for (int i = 1; i <= m; i++) cout << ans[i] << '\n';
  return 0;
}
