#include <bits/stdc++.h>
using namespace std;
int n, m, s[200005], tot, ta, tb;
vector<pair<int, int> > v[200005];
bool vis[200005];
int ans[200005];
int sum[200005];
void dfs(int a) {
  vis[a] = 1;
  sum[a] = s[a];
  for (int i = 0; i < v[a].size(); i++)
    if (vis[v[a][i].first] != 1) {
      dfs(v[a][i].first);
      sum[a] += sum[v[a][i].first];
      if (v[a][i].second > 0)
        ans[v[a][i].second] = sum[v[a][i].first];
      else
        ans[-v[a][i].second] = -sum[v[a][i].first];
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", s + i);
    tot += s[i];
  }
  if (tot)
    printf("Impossible\n");
  else {
    printf("Possible\n");
    scanf("%d", &m);
    for (int i = 1; i <= m; i++) {
      scanf("%d%d", &ta, &tb);
      v[ta].push_back({tb, i});
      v[tb].push_back({ta, -i});
    }
    dfs(1);
    for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
  }
  return 0;
}
