#include <bits/stdc++.h>
using namespace std;
const int maxm = 2e5 + 5;
vector<pair<int, int> > g[maxm];
int mark[maxm];
int ans[maxm];
int s[maxm];
int n, m;
void dfs(int x) {
  mark[x] = 1;
  for (auto i : g[x]) {
    int v = i.first, id = i.second;
    if (mark[v]) continue;
    dfs(v);
    ans[abs(id)] = s[v] * (id > 0 ? 1 : -1);
    s[x] += s[v];
  }
}
void solve() {
  cin >> n;
  int sum = 0;
  for (int i = 1; i <= n; i++) cin >> s[i], sum += s[i];
  if (sum != 0) {
    cout << "Impossible" << endl;
    return;
  }
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back({b, i});
    g[b].push_back({a, -i});
  }
  dfs(1);
  cout << "Possible" << endl;
  for (int i = 1; i <= m; i++) {
    cout << ans[i] << endl;
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
