#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = ' ';
  while (!isdigit(ch)) {
    ch = getchar();
    if (ch == '-') f = -1;
  }
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
struct node {
  int next;
  int to;
  int f;
  int w;
} bian[600050];
long long ans;
int a[200050];
int tot;
int first[200050];
int n;
int m;
void add(register int x, register int y, register int fang) {
  tot++;
  bian[tot].next = first[x];
  first[x] = tot;
  bian[tot].to = y;
  bian[tot].f = fang;
  bian[tot].w = 0;
}
bool bz[200050];
bool BZ = 0;
int wa;
inline void send(int x) {
  bz[x] = 1;
  register int p = first[x];
  while (p != 0) {
    register int o = bian[p].to;
    if (bz[o] == 0) {
      bz[o] = 1;
      bian[p].w -= wa;
      wa = wa + a[o];
      send(o);
      bian[p].w += wa;
    }
    p = bian[p].next;
  }
}
int main() {
  n = read();
  for (register int i = 1; i <= n; i++) {
    a[i] = read();
    ans += a[i];
  }
  if (ans != 0) {
    cout << "Impossible";
    return 0;
  }
  cin >> m;
  for (register int i = 1; i <= m; i++) {
    register int x, y;
    x = read();
    y = read();
    add(x, y, 1);
    add(y, x, -1);
  }
  wa = a[1];
  a[1] = 0;
  send(1);
  if (wa != 0) {
    cout << "Impossible";
    return 0;
  } else
    cout << "Possible" << endl;
  for (int i = 1; i <= tot; i++) {
    register int ff = 0;
    ff = bian[i].w * bian[i].f;
    i++;
    ff += bian[i].w * bian[i].f;
    cout << ff << endl;
  }
  return 0;
}
