#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
int n, q;
int a[N];
int tree[3 * N][101];
void build(int tl = 1, int tr = n, int td = 1) {
  if (tl > tr) return;
  for (int i = 1; i <= 100; i++) tree[td][i] = i;
  if (tl == tr) return;
  int tm = (tl + tr) >> 1;
  build(tl, tm, (td << 1));
  build(tm + 1, tr, (td << 1) + 1);
}
void push(int td) {
  for (int i = 1; i <= 100; i++) {
    tree[(td << 1)][i] = tree[td][tree[(td << 1)][i]];
    tree[(td << 1) + 1][i] = tree[td][tree[(td << 1) + 1][i]];
  }
  for (int i = 1; i <= 100; i++) tree[td][i] = i;
}
void update(int l, int r, int x, int y, int tl = 1, int tr = n, int td = 1) {
  if (tl > tr || tr < l || r < tl) return;
  if (l <= tl && tr <= r) {
    for (int i = 1; i <= 100; i++)
      if (tree[td][i] == x) tree[td][i] = y;
    return;
  }
  if (tl != tr) push(td);
  int tm = (tl + tr) >> 1;
  update(l, r, x, y, tl, tm, (td << 1));
  update(l, r, x, y, tm + 1, tr, (td << 1) + 1);
}
void afterqueries(int tl = 1, int tr = n, int td = 1) {
  if (tl > tr) return;
  if (tl == tr) {
    a[tl] = tree[td][a[tl]];
    return;
  }
  push(td);
  int tm = (tl + tr) >> 1;
  afterqueries(tl, tm, (td << 1));
  afterqueries(tm + 1, tr, (td << 1) + 1);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  build();
  scanf("%d", &q);
  while (q--) {
    int l, r, x, y;
    scanf("%d %d %d %d", &l, &r, &x, &y);
    update(l, r, x, y);
  }
  afterqueries();
  for (int i = 1; i <= n; i++) printf("%d ", a[i]);
}
