#include <bits/stdc++.h>
using namespace std;
bool vis[200011];
int N, M, s[200011], w[200011], sum;
vector<pair<int, int> > adj[200011];
void dfs(int x) {
  vis[x] = true;
  for (auto i : adj[x]) {
    if (vis[i.first]) continue;
    dfs(i.first);
    int id = abs(i.second) + 0.00001;
    int dir = i.second / id;
    w[id] = s[i.first] * dir;
    s[x] += dir * w[id];
  }
}
int main() {
  if (fopen("data.in", "r")) freopen("data.in", "r", stdin);
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &s[i]);
    sum += s[i];
  }
  if (sum) {
    printf("Impossible\n");
    return 0;
  }
  scanf("%d", &M);
  for (int i = 1; i <= M; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--;
    b--;
    adj[a].push_back(make_pair(b, i));
    adj[b].push_back(make_pair(a, -i));
  }
  dfs(0);
  printf("Possible\n");
  for (int i = 1; i <= M; i++) printf("%d\n", w[i]);
}
