#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
unsigned char a[1 << 20];
int n, q;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%hhu", a + i);
  scanf("%d", &q);
  while (q--) {
    int l, r;
    unsigned char x, y;
    scanf("%d%d%hhu%hhu", &l, &r, &x, &y);
    for (int i = l; i <= r; i++) (a[i] == x ? a[i] = y : 1);
  }
  for (int i = 1; i <= n; i++) printf("%hhu ", a[i]);
}
