#include <bits/stdc++.h>
using namespace std;
int n, s[200003], m, cnt, ans[200003];
vector<pair<int, int> > v[200003], g[200003];
bool vis[200003];
int dfs(int x) {
  vis[x] = 1;
  int ret = 0, tmp;
  for (int i = 0; i < v[x].size(); i++)
    if (!vis[v[x][i].first]) {
      tmp = dfs(v[x][i].first);
      ret += tmp;
      ans[v[x][i].second] = -tmp;
    }
  for (int i = 0; i < g[x].size(); i++)
    if (!vis[g[x][i].first]) {
      tmp = dfs(g[x][i].first);
      ret += tmp;
      ans[g[x][i].second] = tmp;
    }
  return ret - s[x];
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%d", s + i), cnt += s[i];
  cin >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--;
    y--;
    v[x].push_back(make_pair(y, i));
    g[y].push_back(make_pair(x, i));
  }
  if (cnt) {
    cout << "Impossible";
    return 0;
  }
  cout << "Possible";
  dfs(0);
  for (int i = 0; i < m; i++) printf("\n%d", ans[i]);
}
