#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int r;
  int s = 0, c;
  for (; !isdigit(c = getchar()); s = c)
    ;
  for (r = c ^ 48; isdigit(c = getchar()); (r *= 10) += c ^ 48)
    ;
  return s ^ 45 ? r : -r;
}
int s[200000 + 5], X[200000 + 5], U[200000 + 5], V[200000 + 5], Ans[200000 + 5],
    n, m;
bool book[200000 + 5];
vector<int> e[200000 + 5];
void DFS(int p) {
  book[p] = true;
  int v;
  for (int i : e[p])
    if (!book[v = X[i] ^ p]) {
      DFS(v);
      Ans[i] = s[v] * (p == U[i] ? 1 : -1);
      s[p] += s[v];
    }
}
int main() {
  n = read();
  generate(s + 1, s + n + 1, read);
  m = read();
  for (register int i = 1; i <= m; e[U[i] = read()].push_back(i),
                    e[V[i] = read()].push_back(i), X[i] = U[i] ^ V[i], i++)
    ;
  DFS(1);
  if (s[1]) return puts("Impossible"), 0;
  puts("Possible");
  for (register int i = 1; i <= m; printf("%d\n", Ans[i++]))
    ;
  return 0;
}
