#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
template <typename T>
int sgn(T val) {
  return (T(0) < val) - (val < T(0));
}
long long read() {
  long long x = 0;
  bool q = 0;
  char c = getchar();
  while (!isdigit(c)) q |= (c == '-'), c = getchar();
  while (isdigit(c)) x = (x << 1) + (x << 3) + c - '0', c = getchar();
  return q ? -x : x;
}
char buffer[22], len_b = 0;
void print(long long x, char q = '\n') {
  if (x < 0) putchar('-'), x = -x;
  if (x == 0) putchar('0');
  buffer[len_b++] = q;
  while (x > 0) buffer[len_b++] = x % 10 + '0', x /= 10;
  while (len_b) putchar(buffer[--len_b]);
}
string read_s() {
  string s;
  char c = getchar();
  while (c == ' ' || c == '\t' || c == '\n') c = getchar();
  while (c != ' ' && c != '\t' && c != '\n') s += c, c = getchar();
  return s;
}
void print_s(string s, char q = '\n') {
  for (char c : s) putchar(c);
  putchar(q);
}
const int MAX_N = 200002;
int a[MAX_N], ans[MAX_N];
bool used[MAX_N];
vector<pair<int, int> > adj[MAX_N];
int dfs(int x = 0) {
  int e = a[x];
  used[x] = 1;
  int ptr = -1;
  for (auto u : adj[x])
    if (!used[u.first]) {
      int f = dfs(u.first);
      if (u.second > 0)
        ans[u.second - 1] = f;
      else
        ans[-u.second - 1] = -f;
      e += f;
    }
  return e;
}
int main() {
  int n = read();
  long long wv = 0;
  for (int i = 0; i < n; i++) a[i] = read(), wv += a[i];
  if (wv != 0)
    puts("Impossible");
  else {
    puts("Possible");
    int m = read();
    for (int i = 1; i <= m; i++) {
      int x = read() - 1, y = read() - 1;
      adj[x].push_back({y, i});
      adj[y].push_back({x, -i});
    }
    for (int i = 0; i < n; i++)
      if (!used[i]) dfs(i);
    for (int i = 0; i < m; i++) print(ans[i]);
  }
}
