#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 22;
int n, m;
long long cap[N];
int res[N];
int sz[N];
pair<int, int> edge[N];
bool mark[N], eg[N];
vector<int> G[N];
void dfs(int v) {
  mark[v] = 1;
  for (auto& e : (G[v])) {
    int u = edge[e].first + edge[e].second - v;
    if (mark[u]) continue;
    eg[e] = 1;
    dfs(u);
  }
}
int main() {
  cin >> n;
  long long sum = 0;
  for (int i = 0; i < (n); i++) cin >> cap[i], sum += cap[i];
  if (sum) return cout << "Impossible", 0;
  cin >> m;
  for (int i = 0; i < (m); i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    edge[i] = {x, y};
    G[x].push_back(i);
    G[y].push_back(i);
  }
  cout << "Possible" << endl;
  dfs(0);
  vector<int> vv;
  for (int i = 0; i < (n); i++) {
    for (auto& e : (G[i])) {
      if (!eg[e]) continue;
      sz[i]++;
    }
    if (sz[i] == 1) vv.push_back(i);
  }
  while (vv.size()) {
    int u = vv.back();
    vv.pop_back();
    for (auto& e : (G[u])) {
      if (!eg[e]) continue;
      int r = edge[e].first + edge[e].second - u;
      eg[e] = 0;
      sz[r]--;
      if (sz[r] == 1) vv.push_back(r);
      res[e] = cap[u];
      if (edge[e].first == u) res[e] *= -1;
      cap[r] += cap[u];
    }
  }
  for (int i = 0; i < (m); i++) cout << res[i] << endl;
  return 0;
}
