using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    static List<int[]> g;

    class Dsu
    {
        public readonly List<int> parent;

        public Dsu(int n)
        {
            parent = Enumerable.Range(0, n).ToList();
            g = new List<int[]>();
            for (int i = 0; i < n; i++)
                g.Add(new int[] { -1, -1 });
        }

        public int FindSet(int v)
        {
            if (v == parent[v])
                return v;
            return parent[v] = FindSet(parent[v]);
        }

        public void UnionSets(int a, int b)
        {
            a = FindSet(a);
            b = FindSet(b);
            if (a != b)
            {
                parent[a] = parent[b] = parent.Count;
                g.Add(new[] { a, b });
                parent.Add(parent.Count);
            }
        }
    }

    int[] c;
    int[] tree;

    int Cmp(int l, int r)
    {
        return c2[l] > c2[r] ? l : r;
    }

    void Build(int x, int xl, int xr)
    {
        if (xl == xr)
        {
            tree[x] = xl;
            return;
        }
        int xm = (xl + xr) / 2;
        Build(x * 2, xl, xm);
        Build(x * 2 + 1, xm + 1, xr);
        tree[x] = Cmp(tree[2 * x], tree[2 * x + 1]);
    }

    void Set(int x, int xl, int xr, int idx)
    {
        if (xl == xr)
        {
            c2[xl] = 0;
            return;
        }

        int xm = (xl + xr) / 2;
        if (idx <= xm)
            Set(x * 2, xl, xm, idx);
        else
            Set(x * 2 + 1, xm + 1, xr, idx);
        tree[x] = Cmp(tree[2 * x], tree[2 * x + 1]);
    }

    int Query(int x, int xl, int xr, int l, int r)
    {
        if (l == xl && r == xr)
            return tree[x];
        int xm = (xl + xr) / 2;
        if (r <= xm)
            return Query(x * 2, xl, xm, l, r);
        if (l > xm)
            return Query(x * 2 + 1, xm + 1, xr, l, r);
        return Cmp(Query(x * 2, xl, xm, l, xm), Query(x * 2 + 1, xm + 1, xr, xm + 1, r));
    }

    int n;
    bool[] vis;
    int[] tin, tout, c2;
    int timer;
    void Dfs(int x)
    {
        if (x < n)
            c2[timer] = c[x];
        vis[x] = true;
        tin[x] = timer++;
        foreach (int e in g[x])
            if (e != -1)
                Dfs(e);
        tout[x] = timer;
    }

    public void Solve()
    {
        n = ReadInt();
        int m = ReadInt();
        int q = ReadInt();
        c = ReadIntArray();
        var a = ReadIntMatrix(m);
        var b = ReadIntMatrix(q);

        //n = 200000;
        //m = 199999;
        //q = 500000;
        //c = new int[n];
        //var rnd = new Random(13);
        //for (int i = 0; i < n; i++)
        //    c[i] = rnd.Next(n) + 1;
        //a = new int[m][];
        //for (int i = 0; i < m; i++)
        //    a[i] = new[] { i + 1, i + 2 };
        //b = new int[q][];
        //int cnt = 1;
        //for (int i = 0; i < q; i++)
        //{
        //    b[i] = new int[2];
        //    b[i][0] = rnd.Next(2) + 1;
        //    if (cnt > m)
        //        b[i][0] = 1;
        //    if (b[i][0] == 1)
        //    {
        //        b[i][1] = rnd.Next(n) + 1;
        //    }
        //    else
        //    {
        //        b[i][1] = cnt++;
        //    }
        //}

        var f = new bool[m];
        for (int i = 0; i < q; i++)
        {
            b[i][1]--;
            if (b[i][0] == 2)
                f[b[i][1]] = true;
        }

        var dsu = new Dsu(n);
        for (int i = 0; i < m; i++)
        {
            a[i][0]--;
            a[i][1]--;
            if (!f[i])
                dsu.UnionSets(a[i][0], a[i][1]);
        }

        for (int i = q - 1; i >= 0; i--)
        {
            if (b[i][0] == 1)
            {
                b[i][1] = dsu.FindSet(b[i][1]);
            }
            else
            {
                dsu.UnionSets(a[b[i][1]][0], a[b[i][1]][1]);
            }
        }

        int n2 = dsu.parent.Count;
        tin = new int[n2];
        tout = new int[n2];
        vis = new bool[n2];
        c2 = new int[n2];
        for (int i = n2 - 1; i >= 0; i--)
            if (!vis[i])
                Dfs(i);

        tree = new int[4 * n2];
        Build(1, 0, n2 - 1);
        for (int i = 0; i < q; i++)
            if (b[i][0] == 1)
            {
                int x = Query(1, 0, n2 - 1, tin[b[i][1]], tout[b[i][1]] - 1);
                Write(c2[x]);
                Set(1, 0, n2 - 1, x);
            }
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("input.txt");
        //writer = new StreamWriter("output.txt");
#endif
        try
        {
            //new Solver().Solve();
            var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            thread.Start();
            thread.Join();
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0) currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i]; }
        return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++) lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array) writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++) ret[i] = new T(); return ret; }
    #endregion
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ProblemD
    {
        static bool SAIKI = false;
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var n = (int)NN;
            var m = (int)NN;
            var q = (int)NN;
            var pList = NNList(n);
            var ab = Repeat(0, m).Select(_ => new { a = (int)NN - 1, b = (int)NN - 1 }).ToArray();
            var query = Repeat(0, q).Select(_ => new { t = (int)NN, param = (int)NN }).ToArray();
            var graph = Repeat(0, n).Select(_ => new List<int>()).ToArray();
            var uf = new LIB_UnionFind(n);
            var deleted = new bool[m];
            foreach (var item in query)
            {
                if (item.t == 2) deleted[item.param - 1] = true;
            }
            var procTgtEdgeIndex = new bool[m];
            for (var i = 0; i < m; i++)
            {
                if (!deleted[i])
                {
                    if (uf.Unite(ab[i].a, ab[i].b))
                    {
                        graph[ab[i].a].Add(ab[i].b);
                        graph[ab[i].b].Add(ab[i].a);
                    }
                }
            }
            foreach (var item in query.Reverse())
            {
                if (item.t == 2)
                {
                    var i = item.param - 1;
                    if (uf.Unite(ab[i].a, ab[i].b))
                    {
                        procTgtEdgeIndex[i] = true;
                        graph[ab[i].a].Add(ab[i].b);
                        graph[ab[i].b].Add(ab[i].a);
                    }
                }
            }
            var param = new int[n];
            var qList = new List<LIB_PriorityQueue>();
            var used = new bool[n];
            {
                var done = new bool[n];
                for (var i = 0; i < n; i++)
                {
                    if (!done[i])
                    {
                        var c = qList.Count();
                        var tmpq = new LIB_PriorityQueue();
                        qList.Add(tmpq);
                        var que = new Queue<int>();
                        que.Enqueue(i);
                        done[i] = true;
                        param[i] = c;
                        while (que.Count > 0)
                        {
                            var v = que.Dequeue();
                            foreach (var item in graph[v])
                            {
                                if (done[item]) continue;
                                done[item] = true;
                                param[item] = c;
                                que.Enqueue(item);
                            }
                        }
                    }
                    qList[param[i]].Push((int)pList[i], i);
                }
            }
            var leftVs = new List<int>();
            var rightVs = new List<int>();
            var leftQ = new Queue<(int, int)>();
            var rightQ = new Queue<(int, int)>();
            foreach (var item in query)
            {
                if (item.t == 1)
                {
                    var v = item.param - 1;
                    var p = param[v];
                    var que = qList[p];
                    var value = 0L;
                    while (que.Count > 0)
                    {
                        if (used[que.Peek.Item2] || p != param[que.Peek.Item2]) que.Pop();
                        else
                        {
                            used[que.Peek.Item2] = true;
                            value = que.Pop().Key;
                            break;
                        }
                    }
                    Console.WriteLine(value);
                }
                else
                {
                    var leftV = ab[item.param - 1].a;
                    var rightV = ab[item.param - 1].b;
                    if (!procTgtEdgeIndex[item.param - 1]) continue;
                    leftQ.Clear();
                    rightQ.Clear();
                    var color = param[leftV];
                    var lidx = 0;
                    var ridx = 0;
                    var lv = leftV;
                    var rv = rightV;
                    var lp = rightV;
                    var rp = leftV;
                    var exit = false;
                    leftVs.Clear();
                    rightVs.Clear();
                    leftVs.Add(lv);
                    rightVs.Add(rv);
                    var procVs = leftVs;
                    while (true)
                    {
                        var leftOK = false;
                        while (true)
                        {
                            while (graph[lv].Count > lidx)
                            {
                                var v = graph[lv][lidx++];
                                if (v == lp) continue;
                                if (color != param[v]) continue;
                                leftQ.Enqueue((v, lv));
                                leftVs.Add(v);
                                leftOK = true;
                                break;
                            }
                            if (leftOK) break;
                            if (leftQ.Count == 0)
                            {
                                exit = true;
                                break;
                            }
                            var pop = leftQ.Dequeue();
                            lv = pop.Item1;
                            lp = pop.Item2;
                            lidx = 0;
                        }
                        if (exit) break;
                        var rightOK = false;
                        while (true)
                        {
                            while (graph[rv].Count > ridx)
                            {
                                var v = graph[rv][ridx++];
                                if (v == rp) continue;
                                if (color != param[v]) continue;
                                rightQ.Enqueue((v, rv));
                                rightVs.Add(v);
                                rightOK = true;
                                break;
                            }
                            if (rightOK) break;
                            if (rightQ.Count == 0)
                            {
                                procVs = rightVs;
                                exit = true;
                                break;
                            }
                            var pop = rightQ.Dequeue();
                            rv = pop.Item1;
                            rp = pop.Item2;
                            ridx = 0;
                        }
                        if (exit) break;
                    }
                    var procColorTo = qList.Count;
                    var tmpq = new LIB_PriorityQueue();
                    qList.Add(tmpq);
                    foreach (var item2 in procVs)
                    {
                        if (!used[item2]) tmpq.Push((int)pList[item2], item2);
                        param[item2] = procColorTo;
                    }
                }
            }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static LIB_FastIO fastio = new LIB_FastIODebug();
        static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }
        static long NN => fastio.Long();
        static double ND => fastio.Double();
        static string NS => fastio.Scan();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);
        static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);
        static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
        static bool Chmax<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }
        static bool Chmin<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }
    }
}
namespace Library {
    class LIB_FastIO
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIO() { str = Console.OpenStandardInput(); }
        readonly Stream str;
        readonly byte[] buf = new byte[2048];
        int len, ptr;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        byte read()
        {
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 2048)) <= 0)
                {
                    return 0;
                }
            }
            return buf[ptr++];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = (ret << 3) + (ret << 1) + b - '0';
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
    class LIB_FastIODebug : LIB_FastIO
    {
        Queue<string> param = new Queue<string>();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIODebug() { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string Scan() => NextString();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override long Long() => long.Parse(NextString());
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override double Double() => double.Parse(NextString());
    }
    class LIB_UnionFind<T>
    {
        int[] d;
        T[] v;
        Func<T, T, T> f;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(IEnumerable<T> s, Func<T, T, T> func)
        {
            v = s.ToArray();
            d = Enumerable.Repeat(-1, v.Length).ToArray();
            f = func;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Unite(long x, long y)
        {
            x = Root(x);
            y = Root(y);
            if (x != y)
            {
                d[x] = d[x] + d[y];
                v[x] = f(v[x], v[y]);
                d[y] = (int)x;
            }
            return x != y;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool IsSame(long x, long y) => Root(x) == Root(y);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Root(long x) => d[x] < 0 ? x : d[x] = (int)Root(d[x]);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Count(long x) => -d[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Calc(long x) => v[Root(x)];
    }
    class LIB_UnionFind : LIB_UnionFind<int>
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(long n) : base(Enumerable.Repeat(0, (int)n), (x, y) => x + y) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        new private void Calc(long x) { }
    }
    class LIB_PriorityQueue
    {
        long[] heap;
        int[] dat;
        public (long, int) Peek => (heap[0], dat[0]);
        public long Count
        {
            get;
            private set;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue()
        {
            heap = new long[16];
            dat = new int[16];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(long key, int val)
        {
            if (Count == heap.Length) Expand();
            var i = Count++;
            heap[i] = key;
            dat[i] = val;
            while (i > 0)
            {
                var ni = (i - 1) / 2;
                if (key <= heap[ni]) break;
                heap[i] = heap[ni];
                dat[i] = dat[ni];
                i = ni;
            }
            heap[i] = key;
            dat[i] = val;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<long, int> Pop()
        {
            var ret = new KeyValuePair<long, int>(heap[0], dat[0]);
            var key = heap[--Count];
            var val = dat[Count];
            if (Count == 0) return ret;
            var i = 0; while ((i << 1) + 1 < Count)
            {
                var i1 = (i << 1) + 1;
                var i2 = (i << 1) + 2;
                if (i2 < Count && heap[i1] < heap[i2]) i1 = i2;
                if (key >= heap[i1]) break;
                heap[i] = heap[i1];
                dat[i] = dat[i1];
                i = i1;
            }
            heap[i] = key;
            dat[i] = val;
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Expand()
        {
            var tmp = new long[Count << 1];
            for (var i = 0; i < heap.Length; ++i) tmp[i] = heap[i];
            heap = tmp;
            var tmp2 = new int[Count << 1];
            for (var i = 0; i < dat.Length; ++i) tmp2[i] = dat[i];
            dat = tmp2;
        }
    }
    class LIB_PriorityQueue<T>
    {
        T[] heap;
        Comparison<T> comp;
        public T Peek => heap[0];
        public long Count
        {
            get;
            private set;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, Comparison<T> cmp, bool asc = true)
        {
            heap = new T[cap];
            comp = asc ? cmp : (x, y) => cmp(y, x);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(Comparison<T> cmp, bool asc = true)
        {
            heap = new T[16];
            comp = asc ? cmp : (x, y) => cmp(y, x);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, bool asc = true) : this(cap, Comparer<T>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(bool asc = true) : this(Comparer<T>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(T val)
        {
            if (Count == heap.Length) Expand();
            var i = Count++;
            heap[i] = val;
            while (i > 0)
            {
                var ni = (i - 1) / 2;
                if (comp(val, heap[ni]) >= 0) break;
                heap[i] = heap[ni];
                i = ni;
            }
            heap[i] = val;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Pop()
        {
            var ret = heap[0];
            var val = heap[--Count];
            if (Count == 0) return ret;
            var i = 0; while ((i << 1) + 1 < Count)
            {
                var i1 = (i << 1) + 1;
                var i2 = (i << 1) + 2;
                if (i2 < Count && comp(heap[i1], heap[i2]) > 0) i1 = i2;
                if (comp(val, heap[i1]) <= 0) break;
                heap[i] = heap[i1]; i = i1;
            }
            heap[i] = val;
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Expand()
        {
            var tmp = new T[Count << 1];
            for (var i = 0; i < heap.Length; ++i) tmp[i] = heap[i];
            heap = tmp;
        }
    }
    class LIB_PriorityQueue<TK, TV>
    {
        LIB_PriorityQueue<KeyValuePair<TK, TV>> q;
        public KeyValuePair<TK, TV> Peek => q.Peek;
        public long Count => q.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, Comparison<TK> cmp, bool asc = true)
        {
            q = new LIB_PriorityQueue<KeyValuePair<TK, TV>>(cap, (x, y) => cmp(x.Key, y.Key), asc);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(Comparison<TK> cmp, bool asc = true)
        {
            q = new LIB_PriorityQueue<KeyValuePair<TK, TV>>((x, y) => cmp(x.Key, y.Key), asc);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, bool asc = true) : this(cap, Comparer<TK>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(bool asc = true) : this(Comparer<TK>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(TK k, TV v) => q.Push(new KeyValuePair<TK, TV>(k, v));
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<TK, TV> Pop() => q.Pop();
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ProblemD
    {
        static bool SAIKI = false;
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var n = (int)NN;
            var m = (int)NN;
            var q = (int)NN;
            var pList = NNList(n);
            var ab = Repeat(0, m).Select(_ => new { a = (int)NN - 1, b = (int)NN - 1 }).ToArray();
            var query = Repeat(0, q).Select(_ => new { t = (int)NN, param = (int)NN }).ToArray();
            var graph = Repeat(0, n).Select(_ => new List<int>()).ToArray();
            var uf = new LIB_UnionFind(n);
            var deleted = new bool[m];
            foreach (var item in query)
            {
                if (item.t == 2) deleted[item.param - 1] = true;
            }
            var procTgtEdgeIndex = new bool[m];
            for (var i = 0; i < m; i++)
            {
                if (!deleted[i])
                {
                    if (uf.Unite(ab[i].a, ab[i].b))
                    {
                        graph[ab[i].a].Add(ab[i].b);
                        graph[ab[i].b].Add(ab[i].a);
                    }
                }
            }
            foreach (var item in query.Reverse())
            {
                if (item.t == 2)
                {
                    var i = item.param - 1;
                    if (uf.Unite(ab[i].a, ab[i].b))
                    {
                        procTgtEdgeIndex[i] = true;
                        graph[ab[i].a].Add(ab[i].b);
                        graph[ab[i].b].Add(ab[i].a);
                    }
                }
            }
            var param = new int[n];
            var qList = new List<LIB_PriorityQueue<int, int>>();
            var used = new bool[n];
            {
                var done = new bool[n];
                for (var i = 0; i < n; i++)
                {
                    if (!done[i])
                    {
                        var c = qList.Count();
                        var tmpq = new LIB_PriorityQueue<int, int>(false);
                        qList.Add(tmpq);
                        var que = new Queue<int>();
                        que.Enqueue(i);
                        done[i] = true;
                        param[i] = c;
                        while (que.Count > 0)
                        {
                            var v = que.Dequeue();
                            foreach (var item in graph[v])
                            {
                                if (done[item]) continue;
                                done[item] = true;
                                param[item] = c;
                                que.Enqueue(item);
                            }
                        }
                    }
                    qList[param[i]].Push((int)pList[i], i);
                }
            }
            foreach (var item in query)
            {
                if (item.t == 1)
                {
                    var v = item.param - 1;
                    var p = param[v];
                    var que = qList[p];
                    var value = 0L;
                    while (que.Count > 0)
                    {
                        if (used[que.Peek.Value] || p != param[que.Peek.Value]) que.Pop();
                        else
                        {
                            used[que.Peek.Value] = true;
                            value = que.Pop().Key;
                            break;
                        }
                    }
                    Console.WriteLine(value);
                }
                else
                {
                    var leftV = ab[item.param - 1].a;
                    var rightV = ab[item.param - 1].b;
                    if (!procTgtEdgeIndex[item.param - 1]) continue;
                    var leftQ = new Queue<(int, int)>();
                    var rightQ = new Queue<(int, int)>();
                    var color = param[leftV];
                    var lidx = 0;
                    var ridx = 0;
                    var lv = leftV;
                    var rv = rightV;
                    var lp = rightV;
                    var rp = leftV;
                    var exit = false;
                    var leftVs = new List<int>();
                    var rightVs = new List<int>();
                    leftVs.Add(lv);
                    rightVs.Add(rv);
                    var procVs = leftVs;
                    while (true)
                    {
                        var leftOK = false;
                        while (true)
                        {
                            while (graph[lv].Count > lidx)
                            {
                                var v = graph[lv][lidx++];
                                if (v == lp) continue;
                                if (color != param[v]) continue;
                                leftQ.Enqueue((v, lv));
                                leftVs.Add(v);
                                leftOK = true;
                                break;
                            }
                            if (leftOK) break;
                            if (leftQ.Count == 0)
                            {
                                exit = true;
                                break;
                            }
                            var pop = leftQ.Dequeue();
                            lv = pop.Item1;
                            lp = pop.Item2;
                            lidx = 0;
                        }
                        if (exit) break;
                        var rightOK = false;
                        while (true)
                        {
                            while (graph[rv].Count > ridx)
                            {
                                var v = graph[rv][ridx++];
                                if (v == rp) continue;
                                if (color != param[v]) continue;
                                rightQ.Enqueue((v, rv));
                                rightVs.Add(v);
                                rightOK = true;
                                break;
                            }
                            if (rightOK) break;
                            if (rightQ.Count == 0)
                            {
                                procVs = rightVs;
                                exit = true;
                                break;
                            }
                            var pop = rightQ.Dequeue();
                            rv = pop.Item1;
                            rp = pop.Item2;
                            ridx = 0;
                        }
                        if (exit) break;
                    }
                    var procColorTo = qList.Count;
                    var tmpq = new LIB_PriorityQueue<int, int>(false);
                    qList.Add(tmpq);
                    foreach (var item2 in procVs)
                    {
                        if (!used[item2]) tmpq.Push((int)pList[item2], item2);
                        param[item2] = procColorTo;
                    }
                }
            }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static LIB_FastIO fastio = new LIB_FastIODebug();
        static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }
        static long NN => fastio.Long();
        static double ND => fastio.Double();
        static string NS => fastio.Scan();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);
        static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);
        static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
        static bool Chmax<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }
        static bool Chmin<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }
    }
}
namespace Library {
    class LIB_FastIO
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIO() { str = Console.OpenStandardInput(); }
        readonly Stream str;
        readonly byte[] buf = new byte[2048];
        int len, ptr;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        byte read()
        {
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 2048)) <= 0)
                {
                    return 0;
                }
            }
            return buf[ptr++];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = (ret << 3) + (ret << 1) + b - '0';
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
    class LIB_FastIODebug : LIB_FastIO
    {
        Queue<string> param = new Queue<string>();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIODebug() { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string Scan() => NextString();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override long Long() => long.Parse(NextString());
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override double Double() => double.Parse(NextString());
    }
    class LIB_UnionFind<T>
    {
        int[] d;
        T[] v;
        Func<T, T, T> f;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(IEnumerable<T> s, Func<T, T, T> func)
        {
            v = s.ToArray();
            d = Enumerable.Repeat(-1, v.Length).ToArray();
            f = func;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Unite(long x, long y)
        {
            x = Root(x);
            y = Root(y);
            if (x != y)
            {
                d[x] = d[x] + d[y];
                v[x] = f(v[x], v[y]);
                d[y] = (int)x;
            }
            return x != y;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool IsSame(long x, long y) => Root(x) == Root(y);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Root(long x) => d[x] < 0 ? x : d[x] = (int)Root(d[x]);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Count(long x) => -d[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Calc(long x) => v[Root(x)];
    }
    class LIB_UnionFind : LIB_UnionFind<int>
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(long n) : base(Enumerable.Repeat(0, (int)n), (x, y) => x + y) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        new private void Calc(long x) { }
    }
    class LIB_PriorityQueue
    {
        long[] heap;
        int[] dat;
        public (long, int) Peek => (heap[0], dat[0]);
        public long Count
        {
            get;
            private set;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue()
        {
            heap = new long[8];
            dat = new int[8];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(long key, int val)
        {
            if (Count == heap.Length) Expand();
            var i = Count++;
            heap[i] = key;
            dat[i] = val;
            while (i > 0)
            {
                var ni = (i - 1) / 2;
                if (key >= heap[ni]) break;
                heap[i] = heap[ni];
                dat[i] = dat[ni];
                i = ni;
            }
            heap[i] = key;
            dat[i] = val;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<long, int> Pop()
        {
            var ret = new KeyValuePair<long, int>(heap[0], dat[0]);
            var key = heap[--Count];
            var val = dat[Count];
            if (Count == 0) return ret;
            var i = 0; while ((i << 1) + 1 < Count)
            {
                var i1 = (i << 1) + 1;
                var i2 = (i << 1) + 2;
                if (i2 < Count && heap[i1] > heap[i2]) i1 = i2;
                if (key <= heap[i1]) break;
                heap[i] = heap[i1];
                dat[i] = dat[i1];
                i = i1;
            }
            heap[i] = key;
            dat[i] = val;
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Expand()
        {
            var tmp = new long[Count << 1];
            for (var i = 0; i < heap.Length; ++i) tmp[i] = heap[i];
            heap = tmp;
            var tmp2 = new int[Count << 1];
            for (var i = 0; i < dat.Length; ++i) tmp2[i] = dat[i];
            dat = tmp2;
        }
    }
    class LIB_PriorityQueue<T>
    {
        T[] heap;
        Comparison<T> comp;
        public T Peek => heap[0];
        public long Count
        {
            get;
            private set;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, Comparison<T> cmp, bool asc = true)
        {
            heap = new T[cap];
            comp = asc ? cmp : (x, y) => cmp(y, x);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(Comparison<T> cmp, bool asc = true)
        {
            heap = new T[8];
            comp = asc ? cmp : (x, y) => cmp(y, x);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, bool asc = true) : this(cap, Comparer<T>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(bool asc = true) : this(Comparer<T>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(T val)
        {
            if (Count == heap.Length) Expand();
            var i = Count++;
            heap[i] = val;
            while (i > 0)
            {
                var ni = (i - 1) / 2;
                if (comp(val, heap[ni]) >= 0) break;
                heap[i] = heap[ni];
                i = ni;
            }
            heap[i] = val;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Pop()
        {
            var ret = heap[0];
            var val = heap[--Count];
            if (Count == 0) return ret;
            var i = 0; while ((i << 1) + 1 < Count)
            {
                var i1 = (i << 1) + 1;
                var i2 = (i << 1) + 2;
                if (i2 < Count && comp(heap[i1], heap[i2]) > 0) i1 = i2;
                if (comp(val, heap[i1]) <= 0) break;
                heap[i] = heap[i1]; i = i1;
            }
            heap[i] = val;
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Expand()
        {
            var tmp = new T[Count << 1];
            for (var i = 0; i < heap.Length; ++i) tmp[i] = heap[i];
            heap = tmp;
        }
    }
    class LIB_PriorityQueue<TK, TV>
    {
        LIB_PriorityQueue<KeyValuePair<TK, TV>> q;
        public KeyValuePair<TK, TV> Peek => q.Peek;
        public long Count => q.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, Comparison<TK> cmp, bool asc = true)
        {
            q = new LIB_PriorityQueue<KeyValuePair<TK, TV>>(cap, (x, y) => cmp(x.Key, y.Key), asc);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(Comparison<TK> cmp, bool asc = true)
        {
            q = new LIB_PriorityQueue<KeyValuePair<TK, TV>>((x, y) => cmp(x.Key, y.Key), asc);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, bool asc = true) : this(cap, Comparer<TK>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(bool asc = true) : this(Comparer<TK>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(TK k, TV v) => q.Push(new KeyValuePair<TK, TV>(k, v));
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<TK, TV> Pop() => q.Pop();
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ProblemD
    {
        static bool SAIKI = false;
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var n = (int)NN;
            var m = (int)NN;
            var q = (int)NN;
            var pList = NNList(n);
            var ab = Repeat(0, m).Select(_ => new { a = (int)NN - 1, b = (int)NN - 1 }).ToArray();
            var query = Repeat(0, q).Select(_ => new { t = (int)NN, param = (int)NN }).ToArray();
            var graph = Repeat(0, n).Select(_ => new List<int>()).ToArray();
            var uf = new LIB_UnionFind(n);
            var deleted = new bool[m];
            foreach (var item in query)
            {
                if (item.t == 2) deleted[item.param - 1] = true;
            }
            var procTgtEdgeIndex = new bool[m];
            for (var i = 0; i < m; i++)
            {
                if (!deleted[i])
                {
                    if (uf.Unite(ab[i].a, ab[i].b))
                    {
                        graph[ab[i].a].Add(ab[i].b);
                        graph[ab[i].b].Add(ab[i].a);
                    }
                }
            }
            foreach (var item in query.Reverse())
            {
                if (item.t == 2)
                {
                    var i = item.param - 1;
                    if (uf.Unite(ab[i].a, ab[i].b))
                    {
                        procTgtEdgeIndex[i] = true;
                        graph[ab[i].a].Add(ab[i].b);
                        graph[ab[i].b].Add(ab[i].a);
                    }
                }
            }
            var param = new int[n];
            var qList = new List<LIB_PriorityQueue<int, int>>();
            var used = new bool[n];
            {
                var done = new bool[n];
                for (var i = 0; i < n; i++)
                {
                    if (!done[i])
                    {
                        var c = qList.Count();
                        var tmpq = new LIB_PriorityQueue<int, int>(false);
                        qList.Add(tmpq);
                        var que = new Queue<int>();
                        que.Enqueue(i);
                        done[i] = true;
                        param[i] = c;
                        while (que.Count > 0)
                        {
                            var v = que.Dequeue();
                            foreach (var item in graph[v])
                            {
                                if (done[item]) continue;
                                done[item] = true;
                                param[item] = c;
                                que.Enqueue(item);
                            }
                        }
                    }
                    qList[param[i]].Push((int)pList[i], i);
                }
            }
            var leftVs = new List<int>();
            var rightVs = new List<int>();
            var leftQ = new Queue<(int, int)>();
            var rightQ = new Queue<(int, int)>();
            foreach (var item in query)
            {
                if (item.t == 1)
                {
                    var v = item.param - 1;
                    var p = param[v];
                    var que = qList[p];
                    var value = 0L;
                    while (que.Count > 0)
                    {
                        if (used[que.Peek.Value] || p != param[que.Peek.Value]) que.Pop();
                        else
                        {
                            used[que.Peek.Value] = true;
                            value = que.Pop().Key;
                            break;
                        }
                    }
                    Console.WriteLine(value);
                }
                else
                {
                    var leftV = ab[item.param - 1].a;
                    var rightV = ab[item.param - 1].b;
                    if (!procTgtEdgeIndex[item.param - 1]) continue;
                    leftQ.Clear();
                    rightQ.Clear();
                    var color = param[leftV];
                    var lidx = 0;
                    var ridx = 0;
                    var lv = leftV;
                    var rv = rightV;
                    var lp = rightV;
                    var rp = leftV;
                    var exit = false;
                    leftVs.Clear();
                    rightVs.Clear();
                    leftVs.Add(lv);
                    rightVs.Add(rv);
                    var procVs = leftVs;
                    while (true)
                    {
                        var leftOK = false;
                        while (true)
                        {
                            while (graph[lv].Count > lidx)
                            {
                                var v = graph[lv][lidx++];
                                if (v == lp) continue;
                                if (color != param[v]) continue;
                                leftQ.Enqueue((v, lv));
                                leftVs.Add(v);
                                leftOK = true;
                                break;
                            }
                            if (leftOK) break;
                            if (leftQ.Count == 0)
                            {
                                exit = true;
                                break;
                            }
                            var pop = leftQ.Dequeue();
                            lv = pop.Item1;
                            lp = pop.Item2;
                            lidx = 0;
                        }
                        if (exit) break;
                        var rightOK = false;
                        while (true)
                        {
                            while (graph[rv].Count > ridx)
                            {
                                var v = graph[rv][ridx++];
                                if (v == rp) continue;
                                if (color != param[v]) continue;
                                rightQ.Enqueue((v, rv));
                                rightVs.Add(v);
                                rightOK = true;
                                break;
                            }
                            if (rightOK) break;
                            if (rightQ.Count == 0)
                            {
                                procVs = rightVs;
                                exit = true;
                                break;
                            }
                            var pop = rightQ.Dequeue();
                            rv = pop.Item1;
                            rp = pop.Item2;
                            ridx = 0;
                        }
                        if (exit) break;
                    }
                    var procColorTo = qList.Count;
                    var tmpq = new LIB_PriorityQueue<int, int>(false);
                    qList.Add(tmpq);
                    foreach (var item2 in procVs)
                    {
                        if (!used[item2]) tmpq.Push((int)pList[item2], item2);
                        param[item2] = procColorTo;
                    }
                }
            }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static LIB_FastIO fastio = new LIB_FastIODebug();
        static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }
        static long NN => fastio.Long();
        static double ND => fastio.Double();
        static string NS => fastio.Scan();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);
        static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);
        static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
        static bool Chmax<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }
        static bool Chmin<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }
    }
}
namespace Library {
    class LIB_UnionFind<T>
    {
        int[] d;
        T[] v;
        Func<T, T, T> f;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(IEnumerable<T> s, Func<T, T, T> func)
        {
            v = s.ToArray();
            d = Enumerable.Repeat(-1, v.Length).ToArray();
            f = func;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Unite(long x, long y)
        {
            x = Root(x);
            y = Root(y);
            if (x != y)
            {
                d[x] = d[x] + d[y];
                v[x] = f(v[x], v[y]);
                d[y] = (int)x;
            }
            return x != y;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool IsSame(long x, long y) => Root(x) == Root(y);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Root(long x) => d[x] < 0 ? x : d[x] = (int)Root(d[x]);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Count(long x) => -d[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Calc(long x) => v[Root(x)];
    }
    class LIB_UnionFind : LIB_UnionFind<int>
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(long n) : base(Enumerable.Repeat(0, (int)n), (x, y) => x + y) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        new private void Calc(long x) { }
    }
    class LIB_FastIO
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIO() { str = Console.OpenStandardInput(); }
        readonly Stream str;
        readonly byte[] buf = new byte[2048];
        int len, ptr;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        byte read()
        {
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 2048)) <= 0)
                {
                    return 0;
                }
            }
            return buf[ptr++];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = (ret << 3) + (ret << 1) + b - '0';
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
    class LIB_FastIODebug : LIB_FastIO
    {
        Queue<string> param = new Queue<string>();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIODebug() { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string Scan() => NextString();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override long Long() => long.Parse(NextString());
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override double Double() => double.Parse(NextString());
    }
    class LIB_PriorityQueue
    {
        long[] heap;
        int[] dat;
        public (long, int) Peek => (heap[0], dat[0]);
        public long Count
        {
            get;
            private set;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue()
        {
            heap = new long[16];
            dat = new int[16];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(long key, int val)
        {
            if (Count == heap.Length) Expand();
            var i = Count++;
            heap[i] = key;
            dat[i] = val;
            while (i > 0)
            {
                var ni = (i - 1) / 2;
                if (key <= heap[ni]) break;
                heap[i] = heap[ni];
                dat[i] = dat[ni];
                i = ni;
            }
            heap[i] = key;
            dat[i] = val;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<long, int> Pop()
        {
            var ret = new KeyValuePair<long, int>(heap[0], dat[0]);
            var key = heap[--Count];
            var val = dat[Count];
            if (Count == 0) return ret;
            var i = 0; while ((i << 1) + 1 < Count)
            {
                var i1 = (i << 1) + 1;
                var i2 = (i << 1) + 2;
                if (i2 < Count && heap[i1] < heap[i2]) i1 = i2;
                if (key >= heap[i1]) break;
                heap[i] = heap[i1];
                dat[i] = dat[i1];
                i = i1;
            }
            heap[i] = key;
            dat[i] = val;
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Expand()
        {
            var tmp = new long[Count << 1];
            for (var i = 0; i < heap.Length; ++i) tmp[i] = heap[i];
            heap = tmp;
            var tmp2 = new int[Count << 1];
            for (var i = 0; i < dat.Length; ++i) tmp2[i] = dat[i];
            dat = tmp2;
        }
    }
    class LIB_PriorityQueue<T>
    {
        T[] heap;
        Comparison<T> comp;
        public T Peek => heap[0];
        public long Count
        {
            get;
            private set;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, Comparison<T> cmp, bool asc = true)
        {
            heap = new T[cap];
            comp = asc ? cmp : (x, y) => cmp(y, x);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(Comparison<T> cmp, bool asc = true)
        {
            heap = new T[16];
            comp = asc ? cmp : (x, y) => cmp(y, x);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, bool asc = true) : this(cap, Comparer<T>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(bool asc = true) : this(Comparer<T>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(T val)
        {
            if (Count == heap.Length) Expand();
            var i = Count++;
            heap[i] = val;
            while (i > 0)
            {
                var ni = (i - 1) / 2;
                if (comp(val, heap[ni]) >= 0) break;
                heap[i] = heap[ni];
                i = ni;
            }
            heap[i] = val;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Pop()
        {
            var ret = heap[0];
            var val = heap[--Count];
            if (Count == 0) return ret;
            var i = 0; while ((i << 1) + 1 < Count)
            {
                var i1 = (i << 1) + 1;
                var i2 = (i << 1) + 2;
                if (i2 < Count && comp(heap[i1], heap[i2]) > 0) i1 = i2;
                if (comp(val, heap[i1]) <= 0) break;
                heap[i] = heap[i1]; i = i1;
            }
            heap[i] = val;
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Expand()
        {
            var tmp = new T[Count << 1];
            for (var i = 0; i < heap.Length; ++i) tmp[i] = heap[i];
            heap = tmp;
        }
    }
    class LIB_PriorityQueue<TK, TV>
    {
        LIB_PriorityQueue<KeyValuePair<TK, TV>> q;
        public KeyValuePair<TK, TV> Peek => q.Peek;
        public long Count => q.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, Comparison<TK> cmp, bool asc = true)
        {
            q = new LIB_PriorityQueue<KeyValuePair<TK, TV>>(cap, (x, y) => cmp(x.Key, y.Key), asc);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(Comparison<TK> cmp, bool asc = true)
        {
            q = new LIB_PriorityQueue<KeyValuePair<TK, TV>>((x, y) => cmp(x.Key, y.Key), asc);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, bool asc = true) : this(cap, Comparer<TK>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(bool asc = true) : this(Comparer<TK>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(TK k, TV v) => q.Push(new KeyValuePair<TK, TV>(k, v));
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<TK, TV> Pop() => q.Pop();
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ProblemD
    {
        static bool SAIKI = false;
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var n = (int)NN;
            var m = (int)NN;
            var q = (int)NN;
            var pList = NNList(n);
            var ab = Repeat(0, m).Select(_ => new { a = (int)NN - 1, b = (int)NN - 1 }).ToArray();
            var query = Repeat(0, q).Select(_ => new { t = (int)NN, param = (int)NN }).ToArray();
            var graph = Repeat(0, n).Select(_ => new List<int>()).ToArray();
            var uf = new LIB_UnionFind(n);
            var deleted = new bool[m];
            foreach (var item in query)
            {
                if (item.t == 2) deleted[item.param - 1] = true;
            }
            var procTgtEdgeIndex = new bool[m];
            for (var i = 0; i < m; i++)
            {
                if (!deleted[i])
                {
                    if (uf.Unite(ab[i].a, ab[i].b))
                    {
                        graph[ab[i].a].Add(ab[i].b);
                        graph[ab[i].b].Add(ab[i].a);
                    }
                }
            }
            foreach (var item in query.Reverse())
            {
                if (item.t == 2)
                {
                    var i = item.param - 1;
                    if (uf.Unite(ab[i].a, ab[i].b))
                    {
                        procTgtEdgeIndex[i] = true;
                        graph[ab[i].a].Add(ab[i].b);
                        graph[ab[i].b].Add(ab[i].a);
                    }
                }
            }
            var param = new int[n];
            var qList = new List<LIB_PriorityQueue<int, int>>();
            var used = new bool[n];
            {
                var done = new bool[n];
                for (var i = 0; i < n; i++)
                {
                    if (!done[i])
                    {
                        var c = qList.Count();
                        var tmpq = new LIB_PriorityQueue<int, int>(false);
                        qList.Add(tmpq);
                        var que = new Queue<int>();
                        que.Enqueue(i);
                        done[i] = true;
                        param[i] = c;
                        while (que.Count > 0)
                        {
                            var v = que.Dequeue();
                            foreach (var item in graph[v])
                            {
                                if (done[item]) continue;
                                done[item] = true;
                                param[item] = c;
                                que.Enqueue(item);
                            }
                        }
                    }
                    qList[param[i]].Push((int)pList[i], i);
                }
            }
            foreach (var item in query)
            {
                if (item.t == 1)
                {
                    var v = item.param - 1;
                    var p = param[v];
                    var que = qList[p];
                    var value = 0L;
                    while (que.Count > 0)
                    {
                        if (used[que.Peek.Value] || p != param[que.Peek.Value]) que.Pop();
                        else
                        {
                            used[que.Peek.Value] = true;
                            value = que.Pop().Key;
                            break;
                        }
                    }
                    Console.WriteLine(value);
                }
                else
                {
                    var leftV = ab[item.param - 1].a;
                    var rightV = ab[item.param - 1].b;
                    if (!procTgtEdgeIndex[item.param - 1]) continue;
                    var leftQ = new Queue<(int, int)>();
                    var rightQ = new Queue<(int, int)>();
                    var color = param[leftV];
                    var lidx = 0;
                    var ridx = 0;
                    var lv = leftV;
                    var rv = rightV;
                    var lp = rightV;
                    var rp = leftV;
                    var exit = false;
                    var leftVs = new List<int>();
                    var rightVs = new List<int>();
                    leftVs.Add(lv);
                    rightVs.Add(rv);
                    var procVs = leftVs;
                    while (true)
                    {
                        var leftOK = false;
                        while (true)
                        {
                            while (graph[lv].Count > lidx)
                            {
                                var v = graph[lv][lidx++];
                                if (v == lp) continue;
                                if (color != param[v]) continue;
                                leftQ.Enqueue((v, lv));
                                leftVs.Add(v);
                                leftOK = true;
                                break;
                            }
                            if (leftOK) break;
                            if (leftQ.Count == 0)
                            {
                                exit = true;
                                break;
                            }
                            var pop = leftQ.Dequeue();
                            lv = pop.Item1;
                            lp = pop.Item2;
                            lidx = 0;
                        }
                        if (exit) break;
                        var rightOK = false;
                        while (true)
                        {
                            while (graph[rv].Count > ridx)
                            {
                                var v = graph[rv][ridx++];
                                if (v == rp) continue;
                                if (color != param[v]) continue;
                                rightQ.Enqueue((v, rv));
                                rightVs.Add(v);
                                rightOK = true;
                                break;
                            }
                            if (rightOK) break;
                            if (rightQ.Count == 0)
                            {
                                procVs = rightVs;
                                exit = true;
                                break;
                            }
                            var pop = rightQ.Dequeue();
                            rv = pop.Item1;
                            rp = pop.Item2;
                            ridx = 0;
                        }
                        if (exit) break;
                    }
                    var procColorTo = qList.Count;
                    var tmpq = new LIB_PriorityQueue<int, int>(false);
                    qList.Add(tmpq);
                    foreach (var item2 in procVs)
                    {
                        if (!used[item2]) tmpq.Push((int)pList[item2], item2);
                        param[item2] = procColorTo;
                    }
                }
            }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static LIB_FastIO fastio = new LIB_FastIODebug();
        static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }
        static long NN => fastio.Long();
        static double ND => fastio.Double();
        static string NS => fastio.Scan();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);
        static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);
        static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
        static bool Chmax<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }
        static bool Chmin<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }
    }
}
namespace Library {
    class LIB_PriorityQueue
    {
        long[] heap;
        int[] dat;
        public (long, int) Peek => (heap[0], dat[0]);
        public long Count
        {
            get;
            private set;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue()
        {
            heap = new long[16];
            dat = new int[16];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(long key, int val)
        {
            if (Count == heap.Length) Expand();
            var i = Count++;
            heap[i] = key;
            dat[i] = val;
            while (i > 0)
            {
                var ni = (i - 1) / 2;
                if (key >= heap[ni]) break;
                heap[i] = heap[ni];
                dat[i] = dat[ni];
                i = ni;
            }
            heap[i] = key;
            dat[i] = val;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<long, int> Pop()
        {
            var ret = new KeyValuePair<long, int>(heap[0], dat[0]);
            var key = heap[--Count];
            var val = dat[Count];
            if (Count == 0) return ret;
            var i = 0; while ((i << 1) + 1 < Count)
            {
                var i1 = (i << 1) + 1;
                var i2 = (i << 1) + 2;
                if (i2 < Count && heap[i1] > heap[i2]) i1 = i2;
                if (key <= heap[i1]) break;
                heap[i] = heap[i1];
                dat[i] = dat[i1];
                i = i1;
            }
            heap[i] = key;
            dat[i] = val;
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Expand()
        {
            var tmp = new long[Count << 1];
            for (var i = 0; i < heap.Length; ++i) tmp[i] = heap[i];
            heap = tmp;
            var tmp2 = new int[Count << 1];
            for (var i = 0; i < dat.Length; ++i) tmp2[i] = dat[i];
            dat = tmp2;
        }
    }
    class LIB_PriorityQueue<T>
    {
        T[] heap;
        Comparison<T> comp;
        public T Peek => heap[0];
        public long Count
        {
            get;
            private set;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, Comparison<T> cmp, bool asc = true)
        {
            heap = new T[cap];
            comp = asc ? cmp : (x, y) => cmp(y, x);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(Comparison<T> cmp, bool asc = true)
        {
            heap = new T[16];
            comp = asc ? cmp : (x, y) => cmp(y, x);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, bool asc = true) : this(cap, Comparer<T>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(bool asc = true) : this(Comparer<T>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(T val)
        {
            if (Count == heap.Length) Expand();
            var i = Count++;
            heap[i] = val;
            while (i > 0)
            {
                var ni = (i - 1) / 2;
                if (comp(val, heap[ni]) >= 0) break;
                heap[i] = heap[ni];
                i = ni;
            }
            heap[i] = val;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Pop()
        {
            var ret = heap[0];
            var val = heap[--Count];
            if (Count == 0) return ret;
            var i = 0; while ((i << 1) + 1 < Count)
            {
                var i1 = (i << 1) + 1;
                var i2 = (i << 1) + 2;
                if (i2 < Count && comp(heap[i1], heap[i2]) > 0) i1 = i2;
                if (comp(val, heap[i1]) <= 0) break;
                heap[i] = heap[i1]; i = i1;
            }
            heap[i] = val;
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Expand()
        {
            var tmp = new T[Count << 1];
            for (var i = 0; i < heap.Length; ++i) tmp[i] = heap[i];
            heap = tmp;
        }
    }
    class LIB_PriorityQueue<TK, TV>
    {
        LIB_PriorityQueue<KeyValuePair<TK, TV>> q;
        public KeyValuePair<TK, TV> Peek => q.Peek;
        public long Count => q.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, Comparison<TK> cmp, bool asc = true)
        {
            q = new LIB_PriorityQueue<KeyValuePair<TK, TV>>(cap, (x, y) => cmp(x.Key, y.Key), asc);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(Comparison<TK> cmp, bool asc = true)
        {
            q = new LIB_PriorityQueue<KeyValuePair<TK, TV>>((x, y) => cmp(x.Key, y.Key), asc);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, bool asc = true) : this(cap, Comparer<TK>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(bool asc = true) : this(Comparer<TK>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(TK k, TV v) => q.Push(new KeyValuePair<TK, TV>(k, v));
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<TK, TV> Pop() => q.Pop();
    }
    class LIB_UnionFind<T>
    {
        int[] d;
        T[] v;
        Func<T, T, T> f;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(IEnumerable<T> s, Func<T, T, T> func)
        {
            v = s.ToArray();
            d = Enumerable.Repeat(-1, v.Length).ToArray();
            f = func;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Unite(long x, long y)
        {
            x = Root(x);
            y = Root(y);
            if (x != y)
            {
                d[x] = d[x] + d[y];
                v[x] = f(v[x], v[y]);
                d[y] = (int)x;
            }
            return x != y;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool IsSame(long x, long y) => Root(x) == Root(y);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Root(long x) => d[x] < 0 ? x : d[x] = (int)Root(d[x]);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Count(long x) => -d[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Calc(long x) => v[Root(x)];
    }
    class LIB_UnionFind : LIB_UnionFind<int>
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(long n) : base(Enumerable.Repeat(0, (int)n), (x, y) => x + y) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        new private void Calc(long x) { }
    }
    class LIB_FastIO
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIO() { str = Console.OpenStandardInput(); }
        readonly Stream str;
        readonly byte[] buf = new byte[2048];
        int len, ptr;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        byte read()
        {
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 2048)) <= 0)
                {
                    return 0;
                }
            }
            return buf[ptr++];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = (ret << 3) + (ret << 1) + b - '0';
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
    class LIB_FastIODebug : LIB_FastIO
    {
        Queue<string> param = new Queue<string>();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIODebug() { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string Scan() => NextString();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override long Long() => long.Parse(NextString());
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override double Double() => double.Parse(NextString());
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ProblemD
    {
        static bool SAIKI = false;
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var n = (int)NN;
            var m = (int)NN;
            var q = (int)NN;
            var pList = NNList(n);
            var ab = Repeat(0, m).Select(_ => new { a = (int)NN - 1, b = (int)NN - 1 }).ToArray();
            var query = Repeat(0, q).Select(_ => new { t = (int)NN, param = (int)NN }).ToArray();
            var uf = new LIB_UnionFind<LIB_RedBlackTree<long>>(Range(0, n).Select(e =>
            {
                var ret = new LIB_RedBlackTree<long>();
                ret.Add(pList[e]);
                return ret;
            }), (x, y) =>
            {
                var rt = LIB_UnionFind.RootVtx.X;
                if (x.Count > y.Count) { var t = x; x = y; y = t; rt = LIB_UnionFind.RootVtx.Y; }
                foreach (var item in y.List()) x.Add(item);
                return (rt, x);
            }, (x, y) =>
            {
                foreach (var item in y.List().ToArray())
                {
                    if (x.ContainsKey(item)) x.Remove(item);
                    else y.Remove(item);
                }
                return (x, y);
            });
            var deleted = new bool[m];
            foreach (var item in query)
            {
                if (item.t == 2) deleted[item.param - 1] = true;
            }
            for (var i = 0; i < m; i++)
            {
                if (!deleted[i]) uf.Unite(ab[i].a, ab[i].b);
            }
            foreach (var item in query.Reverse())
            {
                if (item.t == 2) uf.Unite(ab[item.param - 1].a, ab[item.param - 1].b);
            }
            foreach (var item in query)
            {
                if (item.t == 1)
                {
                    var set = uf.Calc(item.param - 1);
                    var value = 0L;
                    if (set.Count > 0)
                    {
                        value = set.Max();
                        set.Remove(value);
                    }
                    Console.WriteLine(value);
                }
                else uf.Undo();
            }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static LIB_FastIO fastio = new LIB_FastIODebug();
        static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }
        static long NN => fastio.Long();
        static double ND => fastio.Double();
        static string NS => fastio.Scan();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);
        static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);
        static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
        static bool Chmax<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }
        static bool Chmin<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }
    }
}
namespace Library {
    class LIB_FastIO
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIO() { str = Console.OpenStandardInput(); }
        readonly Stream str;
        readonly byte[] buf = new byte[2048];
        int len, ptr;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        byte read()
        {
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 2048)) <= 0)
                {
                    return 0;
                }
            }
            return buf[ptr++];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = (ret << 3) + (ret << 1) + b - '0';
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
    class LIB_FastIODebug : LIB_FastIO
    {
        Queue<string> param = new Queue<string>();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIODebug() { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string Scan() => NextString();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override long Long() => long.Parse(NextString());
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override double Double() => double.Parse(NextString());
    }
    class LIB_UnionFind<T>
    {
        int[] d;
        Stack<(int, int)> h;
        T[] v;
        Func<T, T, (LIB_UnionFind.RootVtx, T)> f;
        Func<T, T, (T, T)> rf;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(IEnumerable<T> s, Func<T, T, (LIB_UnionFind.RootVtx, T)> func, Func<T, T, (T, T)> revFunc)
        {
            v = s.ToArray();
            d = Enumerable.Repeat(-1, v.Length).ToArray();
            f = func;
            rf = revFunc;
            h = new Stack<(int, int)>();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Unite(long x, long y)
        {
            x = Root(x);
            y = Root(y);
            if (x != y)
            {
                var (root, value) = f(v[x], v[y]);
                if (root == LIB_UnionFind.RootVtx.X)
                {
                    h.Push(((int)y, d[y]));
                    h.Push(((int)x, d[x]));
                    d[x] = d[x] + d[y];
                    d[y] = (int)x;
                    v[x] = value;
                }
                else
                {
                    h.Push(((int)x, d[x]));
                    h.Push(((int)y, d[y]));
                    d[y] = d[x] + d[y];
                    d[x] = (int)y;
                    v[y] = value;
                }
            }
            else
            {
                h.Push(((int)y, d[y]));
                h.Push(((int)x, d[x]));
            }
            return x != y;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Undo()
        {
            var pop1 = h.Pop();
            var pop2 = h.Pop();
            if (pop1.Item1 == pop2.Item1) return;
            d[pop1.Item1] = pop1.Item2;
            d[pop2.Item1] = pop2.Item2;
            (v[pop1.Item1], v[pop2.Item1]) = rf(v[pop1.Item1], v[pop2.Item1]);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool IsSame(long x, long y) => Root(x) == Root(y);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Root(long x) => d[x] < 0 ? x : d[x] = (int)Root(d[x]);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Count(long x) => -d[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Calc(long x) => v[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Snapshot() => h.Clear();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Rollback()
        {
            while (h.Count > 0) Undo();
        }
    }
    class LIB_UnionFind : LIB_UnionFind<int>
    {
        public enum RootVtx { X, Y };
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(long n) : base(Enumerable.Repeat(0, (int)n), (x, y) => (RootVtx.X, x + y), (x, y) =>
        {
            if (x < y) return (x, y - x);
            else return (x - y, y);
        })
        { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        new private void Calc(long x) { }
    }
    class LIB_RedBlackTree
    {
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeMin() => new LIB_RedBlackTree<long, long, long>(long.MaxValue, long.MinValue + 100, Math.Min, (x, y, c) => y, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeMin() => new LIB_RedBlackTree<long, long, long>(long.MaxValue, 0, Math.Min, (x, y, c) => x + y, (x, y) => x + y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeMax() => new LIB_RedBlackTree<long, long, long>(long.MinValue, long.MaxValue - 100, Math.Max, (x, y, c) => y, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeMax() => new LIB_RedBlackTree<long, long, long>(long.MinValue, 0, Math.Max, (x, y, c) => x + y, (x, y) => x + y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeSum() => new LIB_RedBlackTree<long, long, long>(0, long.MaxValue, (x, y) => x + y, (x, y, c) => y * c, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeSum() => new LIB_RedBlackTree<long, long, long>(0, 0, (x, y) => x + y, (x, y, c) => x + y * c, (x, y) => x + y);
    }
    class LIB_RedBlackTree<Key, ValueT, ValueE> where ValueE : IEquatable<ValueE>
    {
        bool ope;
        class Node
        {
            public Node left;
            public Node right;
            public Key key;
            public ValueT val;
            public ValueT dat;
            public ValueE lazy;
            public bool isBlack;
            public int cnt;
            public bool needRecalc;
        }
        Func<ValueT, ValueT, ValueT> f;
        Func<ValueT, ValueE, int, ValueT> g;
        Func<ValueE, ValueE, ValueE> h;
        ValueT ti;
        ValueE ei;
        Comparison<Key> c;
        Node root;
        bool isNeedFix;
        Node lmax;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(ValueT ti, ValueE ei, Func<ValueT, ValueT, ValueT> f, Func<ValueT, ValueE, int, ValueT> g, Func<ValueE, ValueE, ValueE> h, Comparison<Key> c, bool ope = true)
        {
            this.ti = ti;
            this.ei = ei;
            this.f = f;
            this.g = g;
            this.h = h;
            this.c = c;
            this.ope = ope;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(ValueT ti, ValueE ei, Func<ValueT, ValueT, ValueT> f, Func<ValueT, ValueE, int, ValueT> g, Func<ValueE, ValueE, ValueE> h) : this(ti, ei, f, g, h, Comparer<Key>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        bool IsRed(Node n) => n != null && !n.isBlack;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        bool IsBlack(Node n) => n != null && n.isBlack;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        int Cnt(Node n) => n == null ? 0 : n.cnt;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Eval(Node n)
        {
            if (n == null || ei.Equals(n.lazy)) return;
            n.val = g(n.val, n.lazy, 1);
            if (!n.needRecalc) n.dat = g(n.dat, n.lazy, Cnt(n));
            if (n.left != null) n.left.lazy = h(n.left.lazy, n.lazy);
            if (n.right != null) n.right.lazy = h(n.right.lazy, n.lazy);
            n.lazy = ei;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Recalc(Node n)
        {
            if (n == null) return;
            Eval(n);
            if (!n.needRecalc) return;
            n.needRecalc = false;
            n.dat = n.val;
            if (n.left != null)
            {
                Recalc(n.left);
                n.dat = f(n.left.dat, n.dat);
            }
            if (n.right != null)
            {
                Recalc(n.right);
                n.dat = f(n.dat, n.right.dat);
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateL(Node n)
        {
            if (ope) { Eval(n); Eval(n.right); }
            Node m = n.right, t = m.left;
            m.left = n; n.right = t;
            n.cnt -= m.cnt - Cnt(t);
            m.cnt += n.cnt - Cnt(t);
            n.needRecalc = true; m.needRecalc = true;
            return m;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateR(Node n)
        {
            if (ope) { Eval(n); Eval(n.left); }
            Node m = n.left, t = m.right;
            m.right = n; n.left = t;
            n.cnt -= m.cnt - Cnt(t);
            m.cnt += n.cnt - Cnt(t);
            n.needRecalc = true; m.needRecalc = true;
            return m;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateLR(Node n)
        {
            n.left = RotateL(n.left);
            return RotateR(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateRL(Node n)
        {
            n.right = RotateR(n.right);
            return RotateL(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(Key key, ValueT val)
        {
            root = Add(root, key, val);
            root.isBlack = true;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Add(Node n, Key key, ValueT val)
        {
            if (n == null)
            {
                isNeedFix = true;
                return new Node() { key = key, val = val, dat = val, lazy = ei, cnt = 1 };
            }
            if (ope) Eval(n);
            if (c(key, n.key) < 0) n.left = Add(n.left, key, val);
            else n.right = Add(n.right, key, val);
            n.needRecalc = true;
            ++n.cnt;
            return Balance(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Balance(Node n)
        {
            if (!isNeedFix || !IsBlack(n)) return n;
            if (IsRed(n.left) && IsRed(n.left.left))
            {
                n = RotateR(n);
                n.left.isBlack = true;
            }
            else if (IsRed(n.left) && IsRed(n.left.right))
            {
                n = RotateLR(n);
                n.left.isBlack = true;
            }
            else if (IsRed(n.right) && IsRed(n.right.left))
            {
                n = RotateRL(n);
                n.right.isBlack = true;
            }
            else if (IsRed(n.right) && IsRed(n.right.right))
            {
                n = RotateL(n);
                n.right.isBlack = true;
            }
            else isNeedFix = false;
            return n;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(Key key)
        {
            root = Remove(root, key);
            if (root != null) root.isBlack = true;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Remove(Node n, Key key)
        {
            if (ope) Eval(n);
            --n.cnt;
            var r = c(key, n.key);
            if (r < 0)
            {
                n.left = Remove(n.left, key);
                n.needRecalc = true;
                return BalanceL(n);
            }
            if (r > 0)
            {
                n.right = Remove(n.right, key);
                n.needRecalc = true;
                return BalanceR(n);
            }
            if (n.left == null)
            {
                isNeedFix = n.isBlack;
                return n.right;
            }
            n.left = RemoveMax(n.left);
            n.key = lmax.key;
            n.val = lmax.val;
            n.needRecalc = true;
            return BalanceL(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RemoveMax(Node n)
        {
            if (ope) Eval(n);
            --n.cnt;
            if (n.right != null)
            {
                n.right = RemoveMax(n.right);
                n.needRecalc = true;
                return BalanceR(n);
            }
            lmax = n;
            isNeedFix = n.isBlack;
            return n.left;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node BalanceL(Node n)
        {
            if (!isNeedFix) return n;
            if (IsBlack(n.right) && IsRed(n.right.left))
            {
                var b = n.isBlack;
                n = RotateRL(n);
                n.isBlack = b;
                n.left.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.right) && IsRed(n.right.right))
            {
                var b = n.isBlack;
                n = RotateL(n);
                n.isBlack = b;
                n.right.isBlack = true;
                n.left.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.right))
            {
                isNeedFix = n.isBlack;
                n.isBlack = true;
                n.right.isBlack = false;
            }
            else
            {
                n = RotateL(n);
                n.isBlack = true;
                n.left.isBlack = false;
                n.left = BalanceL(n.left);
                isNeedFix = false;
            }
            return n;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node BalanceR(Node n)
        {
            if (!isNeedFix) return n;
            if (IsBlack(n.left) && IsRed(n.left.right))
            {
                var b = n.isBlack;
                n = RotateLR(n);
                n.isBlack = b; n.right.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.left) && IsRed(n.left.left))
            {
                var b = n.isBlack;
                n = RotateR(n);
                n.isBlack = b;
                n.left.isBlack = true;
                n.right.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.left))
            {
                isNeedFix = n.isBlack;
                n.isBlack = true;
                n.left.isBlack = false;
            }
            else
            {
                n = RotateR(n);
                n.isBlack = true;
                n.right.isBlack = false;
                n.right = BalanceR(n.right);
                isNeedFix = false;
            }
            return n;
        }
        public KeyValuePair<Key, ValueT> this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return At(root, i); }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        KeyValuePair<Key, ValueT> At(Node n, long i)
        {
            if (ope) Eval(n);
            if (n.left == null)
            {
                if (i == 0) return new KeyValuePair<Key, ValueT>(n.key, n.val);
                else return At(n.right, i - 1);
            }
            if (n.left.cnt == i) return new KeyValuePair<Key, ValueT>(n.key, n.val);
            if (n.left.cnt > i) return At(n.left, i);
            return At(n.right, i - n.left.cnt - 1);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(Key key)
        {
            var t = LowerBound(key);
            return t < Cnt(root) && c(At(root, t).Key, key) == 0;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(Key key) => UpperBound(root, key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        long UpperBound(Node n, Key key)
        {
            if (n == null) return 0;
            var r = c(key, n.key);
            if (r < 0) return UpperBound(n.left, key);
            return Cnt(n.left) + 1 + UpperBound(n.right, key);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(Key key) => LowerBound(root, key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        long LowerBound(Node n, Key key)
        {
            if (n == null) return 0;
            var r = c(key, n.key);
            if (r <= 0) return LowerBound(n.left, key);
            return Cnt(n.left) + 1 + LowerBound(n.right, key);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, ValueT> Min()
        {
            Node n = root.left, p = root;
            while (n != null)
            {
                p = n;
                if (ope) Eval(p);
                n = n.left;
            }
            return new KeyValuePair<Key, ValueT>(p.key, p.val);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, ValueT> Max()
        {
            Node n = root.right, p = root;
            while (n != null)
            {
                p = n;
                if (ope) Eval(p);
                n = n.right;
            }
            return new KeyValuePair<Key, ValueT>(p.key, p.val);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Update(long l, long r, ValueE val) => Update(root, l, r, val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Update(Node n, long l, long r, ValueE val)
        {
            if (n == null) return;
            Eval(n);
            n.needRecalc = true;
            var lc = Cnt(n.left);
            if (lc < l) Update(n.right, l - lc - 1, r - lc - 1, val);
            else if (r <= lc) Update(n.left, l, r, val);
            else if (l <= 0 && Cnt(n) <= r) n.lazy = val;
            else
            {
                n.val = g(n.val, val, 1);
                if (l < lc) Update(n.left, l, lc, val);
                if (lc + 1 < r) Update(n.right, 0, r - lc - 1, val);
            }
            return;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public ValueT Query(long l, long r) => Query(root, l, r);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        ValueT Query(Node n, long l, long r)
        {
            var v1 = ti; var v2 = ti; var v3 = ti;
            if (n == null) return ti;
            Eval(n);
            var lc = Cnt(n.left);
            if (lc < l) v3 = Query(n.right, l - lc - 1, r - lc - 1);
            else if (r <= lc) v1 = Query(n.left, l, r);
            else if (l <= 0 && Cnt(n) <= r)
            {
                Recalc(n);
                v2 = n.dat;
            }
            else
            {
                if (l < lc) v1 = Query(n.left, l, lc);
                if (lc + 1 < r) v3 = Query(n.right, 0, r - lc - 1);
                v2 = n.val;
            }
            return f(f(v1, v2), v3);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => root != null;
        public long Count => Cnt(root);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<KeyValuePair<Key, ValueT>> List() => L(root);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        IEnumerable<KeyValuePair<Key, ValueT>> L(Node n)
        {
            if (n == null) yield break;
            foreach (var i in L(n.left)) yield return i;
            yield return new KeyValuePair<Key, ValueT>(n.key, n.val);
            foreach (var i in L(n.right)) yield return i;
        }
    }
    class LIB_RedBlackTree<Key, Value>
    {
        LIB_RedBlackTree<Key, Value, int> tree;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(Comparison<Key> c) { tree = new LIB_RedBlackTree<Key, Value, int>(default(Value), 0, null, null, null, c, false); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree() : this(Comparer<Key>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(Key key, Value val) => tree.Add(key, val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(Key key) => tree.Remove(key);
        public KeyValuePair<Key, Value> this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return tree[i]; }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(Key key) => tree.ContainsKey(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(Key key) => tree.UpperBound(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(Key key) => tree.LowerBound(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, Value> Min() => tree.Min();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, Value> Max() => tree.Max();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => tree.Any();
        public long Count => tree.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<KeyValuePair<Key, Value>> List() => tree.List();
    }
    class LIB_RedBlackTree<T>
    {
        LIB_RedBlackTree<T, int, int> tree;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(Comparison<T> c) { tree = new LIB_RedBlackTree<T, int, int>(0, 0, null, null, null, c, false); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree() : this(Comparer<T>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(T val) => tree.Add(val, 0);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(T val) => tree.Remove(val);
        public T this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return tree[i].Key; }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(T val) => tree.ContainsKey(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(T val) => tree.UpperBound(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(T val) => tree.LowerBound(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Min() => tree.Min().Key;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Max() => tree.Max().Key;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => tree.Any();
        public long Count => tree.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<T> List() => tree.List().Select(e => e.Key);
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ProblemD
    {
        static bool SAIKI = false;
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var n = NN;
            var m = NN;
            var q = NN;
            var pList = NNList(n);
            var ab = Repeat(0, m).Select(_ => new { a = NN - 1, b = NN - 1 }).ToArray();
            var query = Repeat(0, q).Select(_ => new { t = NN, param = NN }).ToArray();
            var graph = Repeat(0, n).Select(_ => new HashSet<long>()).ToArray();
            var uf = new LIB_UnionFind(n);
            var deleted = new bool[m];
            foreach (var item in query)
            {
                if (item.t == 2) deleted[item.param - 1] = true;
            }
            for (var i = 0; i < m; i++)
            {
                if (!deleted[i])
                {
                    if (uf.Unite(ab[i].a, ab[i].b))
                    {
                        graph[ab[i].a].Add(ab[i].b);
                        graph[ab[i].b].Add(ab[i].a);
                    }
                }
            }
            foreach (var item in query.Reverse())
            {
                if (item.t == 2)
                {
                    var i = item.param - 1;
                    if (uf.Unite(ab[i].a, ab[i].b))
                    {
                        graph[ab[i].a].Add(ab[i].b);
                        graph[ab[i].b].Add(ab[i].a);
                    }
                }
            }
            var param = new int[n];
            var qList = new List<LIB_PriorityQueue<long, int>>();
            var used = new bool[n];
            {
                var done = new bool[n];
                for (var i = 0; i < n; i++)
                {
                    if (!done[i])
                    {
                        var c = qList.Count();
                        var tmpq = new LIB_PriorityQueue<long, int>(false);
                        qList.Add(tmpq);
                        var que = new Queue<long>();
                        que.Enqueue(i);
                        done[i] = true;
                        param[i] = c;
                        while (que.Count > 0)
                        {
                            var v = que.Dequeue();
                            foreach (var item in graph[v])
                            {
                                if (done[item]) continue;
                                done[item] = true;
                                param[item] = c;
                                que.Enqueue(item);
                            }
                        }
                    }
                    qList[param[i]].Push(pList[i], i);
                }
            }
            foreach (var item in query)
            {
                if (item.t == 1)
                {
                    var v = item.param - 1;
                    var p = param[v];
                    var que = qList[p];
                    var value = 0L;
                    while (que.Count > 0)
                    {
                        if (used[que.Peek.Value]) que.Pop();
                        else
                        {
                            used[que.Peek.Value] = true;
                            value = que.Pop().Key;
                            break;
                        }
                    }
                    Console.WriteLine(value);
                }
                else
                {
                    var leftV = ab[item.param - 1].a;
                    var rightV = ab[item.param - 1].b;
                    if (!graph[leftV].Contains(rightV)) continue;
                    var leftQ = new Queue<long>();
                    var rightQ = new Queue<long>();
                    leftQ.Enqueue(leftV);
                    rightQ.Enqueue(rightV);
                    var color = param[leftV];
                    var procV = leftV;
                    var done = new bool[n];
                    done[leftV] = true;
                    done[rightV] = true;
                    while (true)
                    {
                        if (leftQ.Count == 0) break;
                        if (rightQ.Count == 0)
                        {
                            procV = rightV;
                            break;
                        }
                        foreach (var item2 in graph[leftQ.Dequeue()])
                        {
                            if (done[item2]) continue;
                            if (param[item2] != color) continue;
                            done[item2] = true;
                            leftQ.Enqueue(item2);
                        }
                        foreach (var item2 in graph[rightQ.Dequeue()])
                        {
                            if (done[item2]) continue;
                            if (param[item2] != color) continue;
                            done[item2] = true;
                            rightQ.Enqueue(item2);
                        }
                    }
                    var procColorFrom = param[procV];
                    var procColorTo = qList.Count;
                    var tmpq = new LIB_PriorityQueue<long, int>(false);
                    qList.Add(tmpq);
                    var procQ = new Queue<long>();
                    procQ.Enqueue(procV);
                    done = new bool[n];
                    done[leftV] = true;
                    done[rightV] = true;
                    tmpq.Push(pList[procV], (int)procV);
                    param[procV] = procColorTo;
                    while (procQ.Count > 0)
                    {
                        foreach (var item2 in graph[procQ.Dequeue()])
                        {
                            if (done[item2]) continue;
                            if (param[item2] != procColorFrom) continue;
                            if (!used[item2]) tmpq.Push(pList[item2], (int)item2);
                            param[item2] = procColorTo;
                            done[item2] = true;
                            procQ.Enqueue(item2);
                        }
                    }
                }
            }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static LIB_FastIO fastio = new LIB_FastIODebug();
        static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }
        static long NN => fastio.Long();
        static double ND => fastio.Double();
        static string NS => fastio.Scan();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);
        static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);
        static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
        static bool Chmax<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }
        static bool Chmin<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }
    }
}
namespace Library {
    class LIB_UnionFind<T>
    {
        int[] d;
        T[] v;
        Func<T, T, T> f;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(IEnumerable<T> s, Func<T, T, T> func)
        {
            v = s.ToArray();
            d = Enumerable.Repeat(-1, v.Length).ToArray();
            f = func;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Unite(long x, long y)
        {
            x = Root(x);
            y = Root(y);
            if (x != y)
            {
                d[x] = d[x] + d[y];
                v[x] = f(v[x], v[y]);
                d[y] = (int)x;
            }
            return x != y;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool IsSame(long x, long y) => Root(x) == Root(y);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Root(long x) => d[x] < 0 ? x : d[x] = (int)Root(d[x]);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Count(long x) => -d[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Calc(long x) => v[Root(x)];
    }
    class LIB_UnionFind : LIB_UnionFind<int>
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(long n) : base(Enumerable.Repeat(0, (int)n), (x, y) => x + y) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        new private void Calc(long x) { }
    }
    class LIB_PriorityQueue
    {
        long[] heap;
        int[] dat;
        public long Count
        {
            get;
            private set;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue()
        {
            heap = new long[16384];
            dat = new int[16384];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(long key, int val)
        {
            if (Count == heap.Length) Expand();
            var i = Count++;
            heap[i] = key;
            dat[i] = val;
            while (i > 0)
            {
                var ni = (i - 1) / 2;
                if (key >= heap[ni]) break;
                heap[i] = heap[ni];
                dat[i] = dat[ni];
                i = ni;
            }
            heap[i] = key;
            dat[i] = val;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<long, int> Pop()
        {
            var ret = new KeyValuePair<long, int>(heap[0], dat[0]);
            var key = heap[--Count];
            var val = dat[Count];
            if (Count == 0) return ret;
            var i = 0; while ((i << 1) + 1 < Count)
            {
                var i1 = (i << 1) + 1;
                var i2 = (i << 1) + 2;
                if (i2 < Count && heap[i1] > heap[i2]) i1 = i2;
                if (key <= heap[i1]) break;
                heap[i] = heap[i1];
                dat[i] = dat[i1];
                i = i1;
            }
            heap[i] = key;
            dat[i] = val;
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Expand()
        {
            var tmp = new long[Count << 1];
            for (var i = 0; i < heap.Length; ++i) tmp[i] = heap[i];
            heap = tmp;
            var tmp2 = new int[Count << 1];
            for (var i = 0; i < dat.Length; ++i) tmp2[i] = dat[i];
            dat = tmp2;
        }
    }
    class LIB_PriorityQueue<T>
    {
        T[] heap;
        Comparison<T> comp;
        public T Peek => heap[0];
        public long Count
        {
            get;
            private set;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, Comparison<T> cmp, bool asc = true)
        {
            heap = new T[cap];
            comp = asc ? cmp : (x, y) => cmp(y, x);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(Comparison<T> cmp, bool asc = true)
        {
            heap = new T[16384];
            comp = asc ? cmp : (x, y) => cmp(y, x);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, bool asc = true) : this(cap, Comparer<T>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(bool asc = true) : this(Comparer<T>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(T val)
        {
            if (Count == heap.Length) Expand();
            var i = Count++;
            heap[i] = val;
            while (i > 0)
            {
                var ni = (i - 1) / 2;
                if (comp(val, heap[ni]) >= 0) break;
                heap[i] = heap[ni];
                i = ni;
            }
            heap[i] = val;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Pop()
        {
            var ret = heap[0];
            var val = heap[--Count];
            if (Count == 0) return ret;
            var i = 0; while ((i << 1) + 1 < Count)
            {
                var i1 = (i << 1) + 1;
                var i2 = (i << 1) + 2;
                if (i2 < Count && comp(heap[i1], heap[i2]) > 0) i1 = i2;
                if (comp(val, heap[i1]) <= 0) break;
                heap[i] = heap[i1]; i = i1;
            }
            heap[i] = val;
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Expand()
        {
            var tmp = new T[Count << 1];
            for (var i = 0; i < heap.Length; ++i) tmp[i] = heap[i];
            heap = tmp;
        }
    }
    class LIB_PriorityQueue<TK, TV>
    {
        LIB_PriorityQueue<KeyValuePair<TK, TV>> q;
        public KeyValuePair<TK, TV> Peek => q.Peek;
        public long Count => q.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, Comparison<TK> cmp, bool asc = true)
        {
            q = new LIB_PriorityQueue<KeyValuePair<TK, TV>>(cap, (x, y) => cmp(x.Key, y.Key), asc);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(Comparison<TK> cmp, bool asc = true)
        {
            q = new LIB_PriorityQueue<KeyValuePair<TK, TV>>((x, y) => cmp(x.Key, y.Key), asc);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, bool asc = true) : this(cap, Comparer<TK>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(bool asc = true) : this(Comparer<TK>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(TK k, TV v) => q.Push(new KeyValuePair<TK, TV>(k, v));
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<TK, TV> Pop() => q.Pop();
    }
    class LIB_FastIO
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIO() { str = Console.OpenStandardInput(); }
        readonly Stream str;
        readonly byte[] buf = new byte[2048];
        int len, ptr;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        byte read()
        {
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 2048)) <= 0)
                {
                    return 0;
                }
            }
            return buf[ptr++];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = (ret << 3) + (ret << 1) + b - '0';
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
    class LIB_FastIODebug : LIB_FastIO
    {
        Queue<string> param = new Queue<string>();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIODebug() { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string Scan() => NextString();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override long Long() => long.Parse(NextString());
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override double Double() => double.Parse(NextString());
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ProblemD
    {
        static bool SAIKI = false;
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var n = (int)NN;
            var m = (int)NN;
            var q = (int)NN;
            var pList = NNList(n);
            var ab = Repeat(0, m).Select(_ => new { a = (int)NN - 1, b = (int)NN - 1 }).ToArray();
            var query = Repeat(0, q).Select(_ => new { t = (int)NN, param = (int)NN }).ToArray();
            var uf = new LIB_UnionFind<LIB_RedBlackTree<long>>(Range(0, n).Select(e =>
            {
                var ret = new LIB_RedBlackTree<long>();
                ret.Add(pList[e]);
                return ret;
            }), (x, y) =>
            {
                var rt = LIB_UnionFind.RootVtx.Y;
                if (x.Count > y.Count) { var t = x; x = y; y = t; rt = LIB_UnionFind.RootVtx.X; }
                foreach (var item in x.List()) y.Add(item);
                return (rt, y);
            }, (x, y) =>
            {
                foreach (var item in y.List().ToArray())
                {
                    if (x.ContainsKey(item)) x.Remove(item);
                    else y.Remove(item);
                }
                return (x, y);
            });
            var deleted = new bool[m];
            foreach (var item in query)
            {
                if (item.t == 2) deleted[item.param - 1] = true;
            }
            for (var i = 0; i < m; i++)
            {
                if (!deleted[i]) uf.Unite(ab[i].a, ab[i].b);
            }
            foreach (var item in query.Reverse())
            {
                if (item.t == 2) uf.Unite(ab[item.param - 1].a, ab[item.param - 1].b);
            }
            foreach (var item in query)
            {
                if (item.t == 1)
                {
                    var set = uf.Calc(item.param - 1);
                    var value = 0L;
                    if (set.Count > 0)
                    {
                        value = set.Max();
                        set.Remove(value);
                    }
                    Console.WriteLine(value);
                }
                else uf.Undo();
            }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static LIB_FastIO fastio = new LIB_FastIODebug();
        static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }
        static long NN => fastio.Long();
        static double ND => fastio.Double();
        static string NS => fastio.Scan();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);
        static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);
        static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
        static bool Chmax<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }
        static bool Chmin<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }
    }
}
namespace Library {
    class LIB_UnionFind<T>
    {
        int[] d;
        Stack<(int, int)> h;
        T[] v;
        Func<T, T, (LIB_UnionFind.RootVtx, T)> f;
        Func<T, T, (T, T)> rf;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(IEnumerable<T> s, Func<T, T, (LIB_UnionFind.RootVtx, T)> func, Func<T, T, (T, T)> revFunc)
        {
            v = s.ToArray();
            d = Enumerable.Repeat(-1, v.Length).ToArray();
            f = func;
            rf = revFunc;
            h = new Stack<(int, int)>();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Unite(long x, long y)
        {
            x = Root(x);
            y = Root(y);
            if (x != y)
            {
                var (root, value) = f(v[x], v[y]);
                if (root == LIB_UnionFind.RootVtx.X)
                {
                    h.Push(((int)y, d[y]));
                    h.Push(((int)x, d[x]));
                    d[x] = d[x] + d[y];
                    d[y] = (int)x;
                    v[x] = value;
                }
                else
                {
                    h.Push(((int)x, d[x]));
                    h.Push(((int)y, d[y]));
                    d[y] = d[x] + d[y];
                    d[x] = (int)y;
                    v[y] = value;
                }
            }
            return x != y;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Undo()
        {
            var pop1 = h.Pop();
            var pop2 = h.Pop();
            if (pop1.Item1 == pop2.Item1) return;
            d[pop1.Item1] = pop1.Item2;
            d[pop2.Item1] = pop2.Item2;
            (v[pop1.Item1], v[pop2.Item1]) = rf(v[pop1.Item1], v[pop2.Item1]);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool IsSame(long x, long y) => Root(x) == Root(y);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Root(long x) => d[x] < 0 ? x : d[x] = (int)Root(d[x]);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Count(long x) => -d[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Calc(long x) => v[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Snapshot() => h.Clear();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Rollback()
        {
            while (h.Count > 0) Undo();
        }
    }
    class LIB_UnionFind : LIB_UnionFind<int>
    {
        public enum RootVtx { X, Y };
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(long n) : base(Enumerable.Repeat(0, (int)n), (x, y) => (RootVtx.X, x + y), (x, y) =>
        {
            if (x < y) return (x, y - x);
            else return (x - y, y);
        })
        { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        new private void Calc(long x) { }
    }
    class LIB_RedBlackTree
    {
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeMin() => new LIB_RedBlackTree<long, long, long>(long.MaxValue, long.MinValue + 100, Math.Min, (x, y, c) => y, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeMin() => new LIB_RedBlackTree<long, long, long>(long.MaxValue, 0, Math.Min, (x, y, c) => x + y, (x, y) => x + y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeMax() => new LIB_RedBlackTree<long, long, long>(long.MinValue, long.MaxValue - 100, Math.Max, (x, y, c) => y, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeMax() => new LIB_RedBlackTree<long, long, long>(long.MinValue, 0, Math.Max, (x, y, c) => x + y, (x, y) => x + y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeSum() => new LIB_RedBlackTree<long, long, long>(0, long.MaxValue, (x, y) => x + y, (x, y, c) => y * c, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeSum() => new LIB_RedBlackTree<long, long, long>(0, 0, (x, y) => x + y, (x, y, c) => x + y * c, (x, y) => x + y);
    }
    class LIB_RedBlackTree<Key, ValueT, ValueE> where ValueE : IEquatable<ValueE>
    {
        bool ope;
        class Node
        {
            public Node left;
            public Node right;
            public Key key;
            public ValueT val;
            public ValueT dat;
            public ValueE lazy;
            public bool isBlack;
            public int cnt;
            public bool needRecalc;
        }
        Func<ValueT, ValueT, ValueT> f;
        Func<ValueT, ValueE, int, ValueT> g;
        Func<ValueE, ValueE, ValueE> h;
        ValueT ti;
        ValueE ei;
        Comparison<Key> c;
        Node root;
        bool isNeedFix;
        Node lmax;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(ValueT ti, ValueE ei, Func<ValueT, ValueT, ValueT> f, Func<ValueT, ValueE, int, ValueT> g, Func<ValueE, ValueE, ValueE> h, Comparison<Key> c, bool ope = true)
        {
            this.ti = ti;
            this.ei = ei;
            this.f = f;
            this.g = g;
            this.h = h;
            this.c = c;
            this.ope = ope;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(ValueT ti, ValueE ei, Func<ValueT, ValueT, ValueT> f, Func<ValueT, ValueE, int, ValueT> g, Func<ValueE, ValueE, ValueE> h) : this(ti, ei, f, g, h, Comparer<Key>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        bool IsRed(Node n) => n != null && !n.isBlack;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        bool IsBlack(Node n) => n != null && n.isBlack;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        int Cnt(Node n) => n == null ? 0 : n.cnt;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Eval(Node n)
        {
            if (n == null || ei.Equals(n.lazy)) return;
            n.val = g(n.val, n.lazy, 1);
            if (!n.needRecalc) n.dat = g(n.dat, n.lazy, Cnt(n));
            if (n.left != null) n.left.lazy = h(n.left.lazy, n.lazy);
            if (n.right != null) n.right.lazy = h(n.right.lazy, n.lazy);
            n.lazy = ei;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Recalc(Node n)
        {
            if (n == null) return;
            Eval(n);
            if (!n.needRecalc) return;
            n.needRecalc = false;
            n.dat = n.val;
            if (n.left != null)
            {
                Recalc(n.left);
                n.dat = f(n.left.dat, n.dat);
            }
            if (n.right != null)
            {
                Recalc(n.right);
                n.dat = f(n.dat, n.right.dat);
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateL(Node n)
        {
            if (ope) { Eval(n); Eval(n.right); }
            Node m = n.right, t = m.left;
            m.left = n; n.right = t;
            n.cnt -= m.cnt - Cnt(t);
            m.cnt += n.cnt - Cnt(t);
            n.needRecalc = true; m.needRecalc = true;
            return m;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateR(Node n)
        {
            if (ope) { Eval(n); Eval(n.left); }
            Node m = n.left, t = m.right;
            m.right = n; n.left = t;
            n.cnt -= m.cnt - Cnt(t);
            m.cnt += n.cnt - Cnt(t);
            n.needRecalc = true; m.needRecalc = true;
            return m;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateLR(Node n)
        {
            n.left = RotateL(n.left);
            return RotateR(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateRL(Node n)
        {
            n.right = RotateR(n.right);
            return RotateL(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(Key key, ValueT val)
        {
            root = Add(root, key, val);
            root.isBlack = true;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Add(Node n, Key key, ValueT val)
        {
            if (n == null)
            {
                isNeedFix = true;
                return new Node() { key = key, val = val, dat = val, lazy = ei, cnt = 1 };
            }
            if (ope) Eval(n);
            if (c(key, n.key) < 0) n.left = Add(n.left, key, val);
            else n.right = Add(n.right, key, val);
            n.needRecalc = true;
            ++n.cnt;
            return Balance(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Balance(Node n)
        {
            if (!isNeedFix || !IsBlack(n)) return n;
            if (IsRed(n.left) && IsRed(n.left.left))
            {
                n = RotateR(n);
                n.left.isBlack = true;
            }
            else if (IsRed(n.left) && IsRed(n.left.right))
            {
                n = RotateLR(n);
                n.left.isBlack = true;
            }
            else if (IsRed(n.right) && IsRed(n.right.left))
            {
                n = RotateRL(n);
                n.right.isBlack = true;
            }
            else if (IsRed(n.right) && IsRed(n.right.right))
            {
                n = RotateL(n);
                n.right.isBlack = true;
            }
            else isNeedFix = false;
            return n;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(Key key)
        {
            root = Remove(root, key);
            if (root != null) root.isBlack = true;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Remove(Node n, Key key)
        {
            if (ope) Eval(n);
            --n.cnt;
            var r = c(key, n.key);
            if (r < 0)
            {
                n.left = Remove(n.left, key);
                n.needRecalc = true;
                return BalanceL(n);
            }
            if (r > 0)
            {
                n.right = Remove(n.right, key);
                n.needRecalc = true;
                return BalanceR(n);
            }
            if (n.left == null)
            {
                isNeedFix = n.isBlack;
                return n.right;
            }
            n.left = RemoveMax(n.left);
            n.key = lmax.key;
            n.val = lmax.val;
            n.needRecalc = true;
            return BalanceL(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RemoveMax(Node n)
        {
            if (ope) Eval(n);
            --n.cnt;
            if (n.right != null)
            {
                n.right = RemoveMax(n.right);
                n.needRecalc = true;
                return BalanceR(n);
            }
            lmax = n;
            isNeedFix = n.isBlack;
            return n.left;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node BalanceL(Node n)
        {
            if (!isNeedFix) return n;
            if (IsBlack(n.right) && IsRed(n.right.left))
            {
                var b = n.isBlack;
                n = RotateRL(n);
                n.isBlack = b;
                n.left.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.right) && IsRed(n.right.right))
            {
                var b = n.isBlack;
                n = RotateL(n);
                n.isBlack = b;
                n.right.isBlack = true;
                n.left.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.right))
            {
                isNeedFix = n.isBlack;
                n.isBlack = true;
                n.right.isBlack = false;
            }
            else
            {
                n = RotateL(n);
                n.isBlack = true;
                n.left.isBlack = false;
                n.left = BalanceL(n.left);
                isNeedFix = false;
            }
            return n;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node BalanceR(Node n)
        {
            if (!isNeedFix) return n;
            if (IsBlack(n.left) && IsRed(n.left.right))
            {
                var b = n.isBlack;
                n = RotateLR(n);
                n.isBlack = b; n.right.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.left) && IsRed(n.left.left))
            {
                var b = n.isBlack;
                n = RotateR(n);
                n.isBlack = b;
                n.left.isBlack = true;
                n.right.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.left))
            {
                isNeedFix = n.isBlack;
                n.isBlack = true;
                n.left.isBlack = false;
            }
            else
            {
                n = RotateR(n);
                n.isBlack = true;
                n.right.isBlack = false;
                n.right = BalanceR(n.right);
                isNeedFix = false;
            }
            return n;
        }
        public KeyValuePair<Key, ValueT> this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return At(root, i); }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        KeyValuePair<Key, ValueT> At(Node n, long i)
        {
            if (ope) Eval(n);
            if (n.left == null)
            {
                if (i == 0) return new KeyValuePair<Key, ValueT>(n.key, n.val);
                else return At(n.right, i - 1);
            }
            if (n.left.cnt == i) return new KeyValuePair<Key, ValueT>(n.key, n.val);
            if (n.left.cnt > i) return At(n.left, i);
            return At(n.right, i - n.left.cnt - 1);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(Key key)
        {
            var t = LowerBound(key);
            return t < Cnt(root) && c(At(root, t).Key, key) == 0;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(Key key) => UpperBound(root, key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        long UpperBound(Node n, Key key)
        {
            if (n == null) return 0;
            var r = c(key, n.key);
            if (r < 0) return UpperBound(n.left, key);
            return Cnt(n.left) + 1 + UpperBound(n.right, key);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(Key key) => LowerBound(root, key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        long LowerBound(Node n, Key key)
        {
            if (n == null) return 0;
            var r = c(key, n.key);
            if (r <= 0) return LowerBound(n.left, key);
            return Cnt(n.left) + 1 + LowerBound(n.right, key);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, ValueT> Min()
        {
            Node n = root.left, p = root;
            while (n != null)
            {
                p = n;
                if (ope) Eval(p);
                n = n.left;
            }
            return new KeyValuePair<Key, ValueT>(p.key, p.val);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, ValueT> Max()
        {
            Node n = root.right, p = root;
            while (n != null)
            {
                p = n;
                if (ope) Eval(p);
                n = n.right;
            }
            return new KeyValuePair<Key, ValueT>(p.key, p.val);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Update(long l, long r, ValueE val) => Update(root, l, r, val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Update(Node n, long l, long r, ValueE val)
        {
            if (n == null) return;
            Eval(n);
            n.needRecalc = true;
            var lc = Cnt(n.left);
            if (lc < l) Update(n.right, l - lc - 1, r - lc - 1, val);
            else if (r <= lc) Update(n.left, l, r, val);
            else if (l <= 0 && Cnt(n) <= r) n.lazy = val;
            else
            {
                n.val = g(n.val, val, 1);
                if (l < lc) Update(n.left, l, lc, val);
                if (lc + 1 < r) Update(n.right, 0, r - lc - 1, val);
            }
            return;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public ValueT Query(long l, long r) => Query(root, l, r);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        ValueT Query(Node n, long l, long r)
        {
            var v1 = ti; var v2 = ti; var v3 = ti;
            if (n == null) return ti;
            Eval(n);
            var lc = Cnt(n.left);
            if (lc < l) v3 = Query(n.right, l - lc - 1, r - lc - 1);
            else if (r <= lc) v1 = Query(n.left, l, r);
            else if (l <= 0 && Cnt(n) <= r)
            {
                Recalc(n);
                v2 = n.dat;
            }
            else
            {
                if (l < lc) v1 = Query(n.left, l, lc);
                if (lc + 1 < r) v3 = Query(n.right, 0, r - lc - 1);
                v2 = n.val;
            }
            return f(f(v1, v2), v3);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => root != null;
        public long Count => Cnt(root);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<KeyValuePair<Key, ValueT>> List() => L(root);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        IEnumerable<KeyValuePair<Key, ValueT>> L(Node n)
        {
            if (n == null) yield break;
            foreach (var i in L(n.left)) yield return i;
            yield return new KeyValuePair<Key, ValueT>(n.key, n.val);
            foreach (var i in L(n.right)) yield return i;
        }
    }
    class LIB_RedBlackTree<Key, Value>
    {
        LIB_RedBlackTree<Key, Value, int> tree;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(Comparison<Key> c) { tree = new LIB_RedBlackTree<Key, Value, int>(default(Value), 0, null, null, null, c, false); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree() : this(Comparer<Key>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(Key key, Value val) => tree.Add(key, val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(Key key) => tree.Remove(key);
        public KeyValuePair<Key, Value> this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return tree[i]; }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(Key key) => tree.ContainsKey(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(Key key) => tree.UpperBound(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(Key key) => tree.LowerBound(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, Value> Min() => tree.Min();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, Value> Max() => tree.Max();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => tree.Any();
        public long Count => tree.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<KeyValuePair<Key, Value>> List() => tree.List();
    }
    class LIB_RedBlackTree<T>
    {
        LIB_RedBlackTree<T, int, int> tree;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(Comparison<T> c) { tree = new LIB_RedBlackTree<T, int, int>(0, 0, null, null, null, c, false); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree() : this(Comparer<T>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(T val) => tree.Add(val, 0);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(T val) => tree.Remove(val);
        public T this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return tree[i].Key; }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(T val) => tree.ContainsKey(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(T val) => tree.UpperBound(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(T val) => tree.LowerBound(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Min() => tree.Min().Key;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Max() => tree.Max().Key;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => tree.Any();
        public long Count => tree.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<T> List() => tree.List().Select(e => e.Key);
    }
    class LIB_FastIO
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIO() { str = Console.OpenStandardInput(); }
        readonly Stream str;
        readonly byte[] buf = new byte[2048];
        int len, ptr;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        byte read()
        {
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 2048)) <= 0)
                {
                    return 0;
                }
            }
            return buf[ptr++];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = (ret << 3) + (ret << 1) + b - '0';
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
    class LIB_FastIODebug : LIB_FastIO
    {
        Queue<string> param = new Queue<string>();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIODebug() { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string Scan() => NextString();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override long Long() => long.Parse(NextString());
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override double Double() => double.Parse(NextString());
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ProblemD
    {
        static bool SAIKI = false;
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var n = (int)NN;
            var m = (int)NN;
            var q = (int)NN;
            var pList = NNList(n);
            var ab = Repeat(0, m).Select(_ => new { a = (int)NN - 1, b = (int)NN - 1 }).ToArray();
            var query = Repeat(0, q).Select(_ => new { t = (int)NN, param = (int)NN }).ToArray();
            var uf = new LIB_UnionFind<LIB_RedBlackTree<long>>(Range(0, n).Select(e =>
            {
                var ret = new LIB_RedBlackTree<long>();
                ret.Add(pList[e]);
                return ret;
            }), (x, y) =>
            {
                foreach (var item in y.List()) x.Add(item);
                return x;
            }, (x, y) =>
            {
                foreach (var item in y.List().ToArray())
                {
                    if (x.ContainsKey(item)) x.Remove(item);
                    else y.Remove(item);
                }
                return (x, y);
            });
            var deleted = new bool[m];
            foreach (var item in query)
            {
                if (item.t == 2) deleted[item.param - 1] = true;
            }
            for (var i = 0; i < m; i++)
            {
                if (!deleted[i]) uf.Unite(ab[i].a, ab[i].b);
            }
            foreach (var item in query.Reverse())
            {
                if (item.t == 2) uf.Unite(ab[item.param - 1].a, ab[item.param - 1].b);
            }
            foreach (var item in query)
            {
                if (item.t == 1)
                {
                    var set = uf.Calc(item.param - 1);
                    var value = 0L;
                    if (set.Count > 0)
                    {
                        value = set.Max();
                        set.Remove(value);
                    }
                    Console.WriteLine(value);
                }
                else uf.Undo();
            }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static LIB_FastIO fastio = new LIB_FastIODebug();
        static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }
        static long NN => fastio.Long();
        static double ND => fastio.Double();
        static string NS => fastio.Scan();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);
        static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);
        static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
        static bool Chmax<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }
        static bool Chmin<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }
    }
}
namespace Library {
    class LIB_UnionFind<T>
    {
        int[] d;
        Stack<(int, int)> h;
        T[] v;
        Func<T, T, T> f;
        Func<T, T, (T, T)> rf;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(IEnumerable<T> s, Func<T, T, T> func, Func<T, T, (T, T)> revFunc)
        {
            v = s.ToArray();
            d = Enumerable.Repeat(-1, v.Length).ToArray();
            f = func;
            rf = revFunc;
            h = new Stack<(int, int)>();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Unite(long x, long y)
        {
            x = Root(x);
            y = Root(y);
            if (d[x] > d[y]) { var t = x; x = y; y = t; }
            h.Push(((int)y, d[y]));
            h.Push(((int)x, d[x]));
            if (x != y)
            {
                d[x] = d[x] + d[y];
                d[y] = (int)x;
                v[x] = f(v[x], v[y]);
            }
            return x != y;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Undo()
        {
            var pop1 = h.Pop();
            var pop2 = h.Pop();
            if (pop1.Item1 == pop2.Item1) return;
            d[pop1.Item1] = pop1.Item2;
            d[pop2.Item1] = pop2.Item2;
            (v[pop1.Item1], v[pop2.Item1]) = rf(v[pop1.Item1], v[pop2.Item1]);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool IsSame(long x, long y) => Root(x) == Root(y);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Root(long x) => d[x] < 0 ? x : d[x] = (int)Root(d[x]);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Count(long x) => -d[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Calc(long x) => v[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Snapshot() => h.Clear();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Rollback()
        {
            while (h.Count > 0) Undo();
        }
    }
    class LIB_UnionFind : LIB_UnionFind<int>
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(long n) : base(Enumerable.Repeat(0, (int)n), (x, y) => x + y, (x, y) =>
        {
            if (x < y) return (x, y - x);
            else return (x - y, y);
        })
        { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        new private void Calc(long x) { }
    }
    class LIB_FastIO
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIO() { str = Console.OpenStandardInput(); }
        readonly Stream str;
        readonly byte[] buf = new byte[2048];
        int len, ptr;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        byte read()
        {
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 2048)) <= 0)
                {
                    return 0;
                }
            }
            return buf[ptr++];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = (ret << 3) + (ret << 1) + b - '0';
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
    class LIB_FastIODebug : LIB_FastIO
    {
        Queue<string> param = new Queue<string>();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIODebug() { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string Scan() => NextString();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override long Long() => long.Parse(NextString());
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override double Double() => double.Parse(NextString());
    }
    class LIB_RedBlackTree
    {
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeMin() => new LIB_RedBlackTree<long, long, long>(long.MaxValue, long.MinValue + 100, Math.Min, (x, y, c) => y, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeMin() => new LIB_RedBlackTree<long, long, long>(long.MaxValue, 0, Math.Min, (x, y, c) => x + y, (x, y) => x + y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeMax() => new LIB_RedBlackTree<long, long, long>(long.MinValue, long.MaxValue - 100, Math.Max, (x, y, c) => y, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeMax() => new LIB_RedBlackTree<long, long, long>(long.MinValue, 0, Math.Max, (x, y, c) => x + y, (x, y) => x + y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeSum() => new LIB_RedBlackTree<long, long, long>(0, long.MaxValue, (x, y) => x + y, (x, y, c) => y * c, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeSum() => new LIB_RedBlackTree<long, long, long>(0, 0, (x, y) => x + y, (x, y, c) => x + y * c, (x, y) => x + y);
    }
    class LIB_RedBlackTree<Key, ValueT, ValueE> where ValueE : IEquatable<ValueE>
    {
        bool ope;
        class Node
        {
            public Node left;
            public Node right;
            public Key key;
            public ValueT val;
            public ValueT dat;
            public ValueE lazy;
            public bool isBlack;
            public int cnt;
            public bool needRecalc;
        }
        Func<ValueT, ValueT, ValueT> f;
        Func<ValueT, ValueE, int, ValueT> g;
        Func<ValueE, ValueE, ValueE> h;
        ValueT ti;
        ValueE ei;
        Comparison<Key> c;
        Node root;
        bool isNeedFix;
        Node lmax;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(ValueT ti, ValueE ei, Func<ValueT, ValueT, ValueT> f, Func<ValueT, ValueE, int, ValueT> g, Func<ValueE, ValueE, ValueE> h, Comparison<Key> c, bool ope = true)
        {
            this.ti = ti;
            this.ei = ei;
            this.f = f;
            this.g = g;
            this.h = h;
            this.c = c;
            this.ope = ope;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(ValueT ti, ValueE ei, Func<ValueT, ValueT, ValueT> f, Func<ValueT, ValueE, int, ValueT> g, Func<ValueE, ValueE, ValueE> h) : this(ti, ei, f, g, h, Comparer<Key>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        bool IsRed(Node n) => n != null && !n.isBlack;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        bool IsBlack(Node n) => n != null && n.isBlack;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        int Cnt(Node n) => n == null ? 0 : n.cnt;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Eval(Node n)
        {
            if (n == null || ei.Equals(n.lazy)) return;
            n.val = g(n.val, n.lazy, 1);
            if (!n.needRecalc) n.dat = g(n.dat, n.lazy, Cnt(n));
            if (n.left != null) n.left.lazy = h(n.left.lazy, n.lazy);
            if (n.right != null) n.right.lazy = h(n.right.lazy, n.lazy);
            n.lazy = ei;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Recalc(Node n)
        {
            if (n == null) return;
            Eval(n);
            if (!n.needRecalc) return;
            n.needRecalc = false;
            n.dat = n.val;
            if (n.left != null)
            {
                Recalc(n.left);
                n.dat = f(n.left.dat, n.dat);
            }
            if (n.right != null)
            {
                Recalc(n.right);
                n.dat = f(n.dat, n.right.dat);
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateL(Node n)
        {
            if (ope) { Eval(n); Eval(n.right); }
            Node m = n.right, t = m.left;
            m.left = n; n.right = t;
            n.cnt -= m.cnt - Cnt(t);
            m.cnt += n.cnt - Cnt(t);
            n.needRecalc = true; m.needRecalc = true;
            return m;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateR(Node n)
        {
            if (ope) { Eval(n); Eval(n.left); }
            Node m = n.left, t = m.right;
            m.right = n; n.left = t;
            n.cnt -= m.cnt - Cnt(t);
            m.cnt += n.cnt - Cnt(t);
            n.needRecalc = true; m.needRecalc = true;
            return m;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateLR(Node n)
        {
            n.left = RotateL(n.left);
            return RotateR(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateRL(Node n)
        {
            n.right = RotateR(n.right);
            return RotateL(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(Key key, ValueT val)
        {
            root = Add(root, key, val);
            root.isBlack = true;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Add(Node n, Key key, ValueT val)
        {
            if (n == null)
            {
                isNeedFix = true;
                return new Node() { key = key, val = val, dat = val, lazy = ei, cnt = 1 };
            }
            if (ope) Eval(n);
            if (c(key, n.key) < 0) n.left = Add(n.left, key, val);
            else n.right = Add(n.right, key, val);
            n.needRecalc = true;
            ++n.cnt;
            return Balance(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Balance(Node n)
        {
            if (!isNeedFix || !IsBlack(n)) return n;
            if (IsRed(n.left) && IsRed(n.left.left))
            {
                n = RotateR(n);
                n.left.isBlack = true;
            }
            else if (IsRed(n.left) && IsRed(n.left.right))
            {
                n = RotateLR(n);
                n.left.isBlack = true;
            }
            else if (IsRed(n.right) && IsRed(n.right.left))
            {
                n = RotateRL(n);
                n.right.isBlack = true;
            }
            else if (IsRed(n.right) && IsRed(n.right.right))
            {
                n = RotateL(n);
                n.right.isBlack = true;
            }
            else isNeedFix = false;
            return n;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(Key key)
        {
            root = Remove(root, key);
            if (root != null) root.isBlack = true;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Remove(Node n, Key key)
        {
            if (ope) Eval(n);
            --n.cnt;
            var r = c(key, n.key);
            if (r < 0)
            {
                n.left = Remove(n.left, key);
                n.needRecalc = true;
                return BalanceL(n);
            }
            if (r > 0)
            {
                n.right = Remove(n.right, key);
                n.needRecalc = true;
                return BalanceR(n);
            }
            if (n.left == null)
            {
                isNeedFix = n.isBlack;
                return n.right;
            }
            n.left = RemoveMax(n.left);
            n.key = lmax.key;
            n.val = lmax.val;
            n.needRecalc = true;
            return BalanceL(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RemoveMax(Node n)
        {
            if (ope) Eval(n);
            --n.cnt;
            if (n.right != null)
            {
                n.right = RemoveMax(n.right);
                n.needRecalc = true;
                return BalanceR(n);
            }
            lmax = n;
            isNeedFix = n.isBlack;
            return n.left;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node BalanceL(Node n)
        {
            if (!isNeedFix) return n;
            if (IsBlack(n.right) && IsRed(n.right.left))
            {
                var b = n.isBlack;
                n = RotateRL(n);
                n.isBlack = b;
                n.left.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.right) && IsRed(n.right.right))
            {
                var b = n.isBlack;
                n = RotateL(n);
                n.isBlack = b;
                n.right.isBlack = true;
                n.left.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.right))
            {
                isNeedFix = n.isBlack;
                n.isBlack = true;
                n.right.isBlack = false;
            }
            else
            {
                n = RotateL(n);
                n.isBlack = true;
                n.left.isBlack = false;
                n.left = BalanceL(n.left);
                isNeedFix = false;
            }
            return n;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node BalanceR(Node n)
        {
            if (!isNeedFix) return n;
            if (IsBlack(n.left) && IsRed(n.left.right))
            {
                var b = n.isBlack;
                n = RotateLR(n);
                n.isBlack = b; n.right.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.left) && IsRed(n.left.left))
            {
                var b = n.isBlack;
                n = RotateR(n);
                n.isBlack = b;
                n.left.isBlack = true;
                n.right.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.left))
            {
                isNeedFix = n.isBlack;
                n.isBlack = true;
                n.left.isBlack = false;
            }
            else
            {
                n = RotateR(n);
                n.isBlack = true;
                n.right.isBlack = false;
                n.right = BalanceR(n.right);
                isNeedFix = false;
            }
            return n;
        }
        public KeyValuePair<Key, ValueT> this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return At(root, i); }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        KeyValuePair<Key, ValueT> At(Node n, long i)
        {
            if (ope) Eval(n);
            if (n.left == null)
            {
                if (i == 0) return new KeyValuePair<Key, ValueT>(n.key, n.val);
                else return At(n.right, i - 1);
            }
            if (n.left.cnt == i) return new KeyValuePair<Key, ValueT>(n.key, n.val);
            if (n.left.cnt > i) return At(n.left, i);
            return At(n.right, i - n.left.cnt - 1);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(Key key)
        {
            var t = LowerBound(key);
            return t < Cnt(root) && c(At(root, t).Key, key) == 0;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(Key key) => UpperBound(root, key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        long UpperBound(Node n, Key key)
        {
            if (n == null) return 0;
            var r = c(key, n.key);
            if (r < 0) return UpperBound(n.left, key);
            return Cnt(n.left) + 1 + UpperBound(n.right, key);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(Key key) => LowerBound(root, key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        long LowerBound(Node n, Key key)
        {
            if (n == null) return 0;
            var r = c(key, n.key);
            if (r <= 0) return LowerBound(n.left, key);
            return Cnt(n.left) + 1 + LowerBound(n.right, key);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, ValueT> Min()
        {
            Node n = root.left, p = root;
            while (n != null)
            {
                p = n;
                if (ope) Eval(p);
                n = n.left;
            }
            return new KeyValuePair<Key, ValueT>(p.key, p.val);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, ValueT> Max()
        {
            Node n = root.right, p = root;
            while (n != null)
            {
                p = n;
                if (ope) Eval(p);
                n = n.right;
            }
            return new KeyValuePair<Key, ValueT>(p.key, p.val);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Update(long l, long r, ValueE val) => Update(root, l, r, val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Update(Node n, long l, long r, ValueE val)
        {
            if (n == null) return;
            Eval(n);
            n.needRecalc = true;
            var lc = Cnt(n.left);
            if (lc < l) Update(n.right, l - lc - 1, r - lc - 1, val);
            else if (r <= lc) Update(n.left, l, r, val);
            else if (l <= 0 && Cnt(n) <= r) n.lazy = val;
            else
            {
                n.val = g(n.val, val, 1);
                if (l < lc) Update(n.left, l, lc, val);
                if (lc + 1 < r) Update(n.right, 0, r - lc - 1, val);
            }
            return;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public ValueT Query(long l, long r) => Query(root, l, r);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        ValueT Query(Node n, long l, long r)
        {
            var v1 = ti; var v2 = ti; var v3 = ti;
            if (n == null) return ti;
            Eval(n);
            var lc = Cnt(n.left);
            if (lc < l) v3 = Query(n.right, l - lc - 1, r - lc - 1);
            else if (r <= lc) v1 = Query(n.left, l, r);
            else if (l <= 0 && Cnt(n) <= r)
            {
                Recalc(n);
                v2 = n.dat;
            }
            else
            {
                if (l < lc) v1 = Query(n.left, l, lc);
                if (lc + 1 < r) v3 = Query(n.right, 0, r - lc - 1);
                v2 = n.val;
            }
            return f(f(v1, v2), v3);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => root != null;
        public long Count => Cnt(root);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<KeyValuePair<Key, ValueT>> List() => L(root);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        IEnumerable<KeyValuePair<Key, ValueT>> L(Node n)
        {
            if (n == null) yield break;
            foreach (var i in L(n.left)) yield return i;
            yield return new KeyValuePair<Key, ValueT>(n.key, n.val);
            foreach (var i in L(n.right)) yield return i;
        }
    }
    class LIB_RedBlackTree<Key, Value>
    {
        LIB_RedBlackTree<Key, Value, int> tree;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(Comparison<Key> c) { tree = new LIB_RedBlackTree<Key, Value, int>(default(Value), 0, null, null, null, c, false); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree() : this(Comparer<Key>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(Key key, Value val) => tree.Add(key, val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(Key key) => tree.Remove(key);
        public KeyValuePair<Key, Value> this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return tree[i]; }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(Key key) => tree.ContainsKey(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(Key key) => tree.UpperBound(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(Key key) => tree.LowerBound(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, Value> Min() => tree.Min();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, Value> Max() => tree.Max();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => tree.Any();
        public long Count => tree.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<KeyValuePair<Key, Value>> List() => tree.List();
    }
    class LIB_RedBlackTree<T>
    {
        LIB_RedBlackTree<T, int, int> tree;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(Comparison<T> c) { tree = new LIB_RedBlackTree<T, int, int>(0, 0, null, null, null, c, false); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree() : this(Comparer<T>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(T val) => tree.Add(val, 0);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(T val) => tree.Remove(val);
        public T this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return tree[i].Key; }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(T val) => tree.ContainsKey(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(T val) => tree.UpperBound(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(T val) => tree.LowerBound(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Min() => tree.Min().Key;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Max() => tree.Max().Key;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => tree.Any();
        public long Count => tree.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<T> List() => tree.List().Select(e => e.Key);
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ProblemD
    {
        static bool SAIKI = false;
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var n = NN;
            var m = NN;
            var q = NN;
            var pList = NNList(n);
            var ab = Repeat(0, m).Select(_ => new { a = NN - 1, b = NN - 1 }).ToArray();
            var query = Repeat(0, q).Select(_ => new { t = NN, param = NN }).ToArray();
            var deleteTgt = new bool[m];
            var uf = new LIB_UnionFind<LIB_PriorityQueue>(pList.Select((e, idx) =>
            {
                var ret = new LIB_PriorityQueue();
                ret.Push(e, idx);
                return ret;
            }), (x, y) =>
            {
                if (x.Count > y.Count)
                {
                    for (var i = 0; i < y.Count; i++)
                    {
                        x.Push(y.heap[i], y.dat[i]);
                    }
                    return x;
                }
                else
                {
                    for (var i = 0; i < x.Count; i++)
                    {
                        y.Push(x.heap[i], x.dat[i]);
                    }
                    return y;
                }
            });
            foreach (var item in query)
            {
                if (item.t == 2) deleteTgt[item.param - 1] = true;
            }
            for (var i = 0; i < m; i++)
            {
                if (!deleteTgt[i])
                {
                    uf.Unite(ab[i].a, ab[i].b);
                }
            }
            var ans = new List<LIB_PriorityQueue>();
            for (var qqq = q - 1; qqq >= 0; qqq--)
            {
                if (query[qqq].t == 1)
                {
                    var v = query[qqq].param - 1;
                    ans.Add(uf.Calc(v));
                }
                else
                {
                    var i = query[qqq].param - 1;
                    uf.Unite(ab[i].a, ab[i].b);
                }
            }
            ans.Reverse();
            var deleted = new bool[n];
            foreach (var item in ans)
            {
                var ok = false;
                while (item.Count > 0)
                {
                    var value = item.Pop();
                    if (!deleted[value.Value])
                    {
                        deleted[value.Value] = true;
                        Console.WriteLine(value.Key);
                        ok = true;
                        break;
                    }
                }
                if (!ok) Console.WriteLine(0);
            }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static LIB_FastIO fastio = new LIB_FastIODebug();
        static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }
        static long NN => fastio.Long();
        static double ND => fastio.Double();
        static string NS => fastio.Scan();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);
        static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);
        static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
        static bool Chmax<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }
        static bool Chmin<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }
    }
}
namespace Library {
    class LIB_FastIO
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIO() { str = Console.OpenStandardInput(); }
        readonly Stream str;
        readonly byte[] buf = new byte[2048];
        int len, ptr;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        byte read()
        {
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 2048)) <= 0)
                {
                    return 0;
                }
            }
            return buf[ptr++];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = (ret << 3) + (ret << 1) + b - '0';
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
    class LIB_FastIODebug : LIB_FastIO
    {
        Queue<string> param = new Queue<string>();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIODebug() { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string Scan() => NextString();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override long Long() => long.Parse(NextString());
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override double Double() => double.Parse(NextString());
    }
    class LIB_UnionFind<T>
    {
        int[] d;
        T[] v;
        Func<T, T, T> f;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(IEnumerable<T> s, Func<T, T, T> func)
        {
            v = s.ToArray();
            d = Enumerable.Repeat(-1, v.Length).ToArray();
            f = func;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Unite(long x, long y)
        {
            x = Root(x);
            y = Root(y);
            if (x != y)
            {
                d[x] = d[x] + d[y];
                v[x] = f(v[x], v[y]);
                d[y] = (int)x;
            }
            return x != y;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool IsSame(long x, long y) => Root(x) == Root(y);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Root(long x) => d[x] < 0 ? x : d[x] = (int)Root(d[x]);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Count(long x) => -d[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Calc(long x) => v[Root(x)];
    }
    class LIB_UnionFind : LIB_UnionFind<int>
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(long n) : base(Enumerable.Repeat(0, (int)n), (x, y) => x + y) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        new private void Calc(long x) { }
    }
    class LIB_PriorityQueue
    {
        public long[] heap;
        public int[] dat;
        public long Count
        {
            get;
            private set;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue()
        {
            heap = new long[163];
            dat = new int[163];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(long key, int val)
        {
            if (Count == heap.Length) Expand();
            var i = Count++;
            heap[i] = key;
            dat[i] = val;
            while (i > 0)
            {
                var ni = (i - 1) / 2;
                if (key <= heap[ni]) break;
                heap[i] = heap[ni];
                dat[i] = dat[ni];
                i = ni;
            }
            heap[i] = key;
            dat[i] = val;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<long, int> Pop()
        {
            var ret = new KeyValuePair<long, int>(heap[0], dat[0]);
            var key = heap[--Count];
            var val = dat[Count];
            if (Count == 0) return ret;
            var i = 0; while ((i << 1) + 1 < Count)
            {
                var i1 = (i << 1) + 1;
                var i2 = (i << 1) + 2;
                if (i2 < Count && heap[i1] < heap[i2]) i1 = i2;
                if (key >= heap[i1]) break;
                heap[i] = heap[i1];
                dat[i] = dat[i1];
                i = i1;
            }
            heap[i] = key;
            dat[i] = val;
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Expand()
        {
            var tmp = new long[Count << 1];
            for (var i = 0; i < heap.Length; ++i) tmp[i] = heap[i];
            heap = tmp;
            var tmp2 = new int[Count << 1];
            for (var i = 0; i < dat.Length; ++i) tmp2[i] = dat[i];
            dat = tmp2;
        }
    }
    class LIB_PriorityQueue<T>
    {
        T[] heap;
        Comparison<T> comp;
        public T Peek => heap[0];
        public long Count
        {
            get;
            private set;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, Comparison<T> cmp, bool asc = true)
        {
            heap = new T[cap];
            comp = asc ? cmp : (x, y) => cmp(y, x);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(Comparison<T> cmp, bool asc = true)
        {
            heap = new T[16384];
            comp = asc ? cmp : (x, y) => cmp(y, x);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, bool asc = true) : this(cap, Comparer<T>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(bool asc = true) : this(Comparer<T>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(T val)
        {
            if (Count == heap.Length) Expand();
            var i = Count++;
            heap[i] = val;
            while (i > 0)
            {
                var ni = (i - 1) / 2;
                if (comp(val, heap[ni]) >= 0) break;
                heap[i] = heap[ni];
                i = ni;
            }
            heap[i] = val;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Pop()
        {
            var ret = heap[0];
            var val = heap[--Count];
            if (Count == 0) return ret;
            var i = 0; while ((i << 1) + 1 < Count)
            {
                var i1 = (i << 1) + 1;
                var i2 = (i << 1) + 2;
                if (i2 < Count && comp(heap[i1], heap[i2]) > 0) i1 = i2;
                if (comp(val, heap[i1]) <= 0) break;
                heap[i] = heap[i1]; i = i1;
            }
            heap[i] = val;
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Expand()
        {
            var tmp = new T[Count << 1];
            for (var i = 0; i < heap.Length; ++i) tmp[i] = heap[i];
            heap = tmp;
        }
    }
    class LIB_PriorityQueue<TK, TV>
    {
        LIB_PriorityQueue<KeyValuePair<TK, TV>> q;
        public KeyValuePair<TK, TV> Peek => q.Peek;
        public long Count => q.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, Comparison<TK> cmp, bool asc = true)
        {
            q = new LIB_PriorityQueue<KeyValuePair<TK, TV>>(cap, (x, y) => cmp(x.Key, y.Key), asc);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(Comparison<TK> cmp, bool asc = true)
        {
            q = new LIB_PriorityQueue<KeyValuePair<TK, TV>>((x, y) => cmp(x.Key, y.Key), asc);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, bool asc = true) : this(cap, Comparer<TK>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(bool asc = true) : this(Comparer<TK>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(TK k, TV v) => q.Push(new KeyValuePair<TK, TV>(k, v));
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<TK, TV> Pop() => q.Pop();
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ProblemD
    {
        static bool SAIKI = false;
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var n = (int)NN;
            var m = (int)NN;
            var q = (int)NN;
            var pList = NNList(n);
            var ab = Repeat(0, m).Select(_ => new { a = (int)NN - 1, b = (int)NN - 1 }).ToArray();
            var query = Repeat(0, q).Select(_ => new { t = (int)NN, param = (int)NN }).ToArray();
            var uf = new LIB_UnionFind<LIB_RedBlackTree<long>>(Range(0, n).Select(e =>
            {
                var ret = new LIB_RedBlackTree<long>();
                ret.Add(pList[e]);
                return ret;
            }), (x, y) =>
            {
                var rt = LIB_UnionFind.RootVtx.Y;
                if (x.Count > y.Count) { var t = x; x = y; y = t; rt = LIB_UnionFind.RootVtx.X; }
                foreach (var item in x.List()) y.Add(item);
                return (rt, y);
            }, (x, y) =>
            {
                foreach (var item in y.List().ToArray())
                {
                    if (x.ContainsKey(item)) x.Remove(item);
                    else y.Remove(item);
                }
                return (x, y);
            });
            var deleted = new bool[m];
            foreach (var item in query)
            {
                if (item.t == 2) deleted[item.param - 1] = true;
            }
            for (var i = 0; i < m; i++)
            {
                if (!deleted[i]) uf.Unite(ab[i].a, ab[i].b);
            }
            foreach (var item in query.Reverse())
            {
                if (item.t == 2) uf.Unite(ab[item.param - 1].a, ab[item.param - 1].b);
            }
            foreach (var item in query)
            {
                if (item.t == 1)
                {
                    var set = uf.Calc(item.param - 1);
                    var value = 0L;
                    if (set.Count > 0)
                    {
                        value = set.Max();
                        set.Remove(value);
                    }
                    Console.WriteLine(value);
                }
                else uf.Undo();
            }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static LIB_FastIO fastio = new LIB_FastIODebug();
        static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }
        static long NN => fastio.Long();
        static double ND => fastio.Double();
        static string NS => fastio.Scan();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);
        static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);
        static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
        static bool Chmax<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }
        static bool Chmin<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }
    }
}
namespace Library {
    class LIB_UnionFind<T>
    {
        int[] d;
        Stack<(int, int)> h;
        T[] v;
        Func<T, T, (LIB_UnionFind.RootVtx, T)> f;
        Func<T, T, (T, T)> rf;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(IEnumerable<T> s, Func<T, T, (LIB_UnionFind.RootVtx, T)> func, Func<T, T, (T, T)> revFunc)
        {
            v = s.ToArray();
            d = Enumerable.Repeat(-1, v.Length).ToArray();
            f = func;
            rf = revFunc;
            h = new Stack<(int, int)>();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Unite(long x, long y)
        {
            x = Root(x);
            y = Root(y);
            if (x != y)
            {
                var (root, value) = f(v[x], v[y]);
                if (root == LIB_UnionFind.RootVtx.X)
                {
                    h.Push(((int)y, d[y]));
                    h.Push(((int)x, d[x]));
                    d[x] = d[x] + d[y];
                    d[y] = (int)x;
                    v[x] = value;
                }
                else
                {
                    h.Push(((int)x, d[x]));
                    h.Push(((int)y, d[y]));
                    d[y] = d[x] + d[y];
                    d[x] = (int)y;
                    v[y] = value;
                }
            }
            else
            {
                h.Push(((int)y, d[y]));
                h.Push(((int)x, d[x]));
            }
            return x != y;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Undo()
        {
            var pop1 = h.Pop();
            var pop2 = h.Pop();
            if (pop1.Item1 == pop2.Item1) return;
            d[pop1.Item1] = pop1.Item2;
            d[pop2.Item1] = pop2.Item2;
            (v[pop1.Item1], v[pop2.Item1]) = rf(v[pop1.Item1], v[pop2.Item1]);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool IsSame(long x, long y) => Root(x) == Root(y);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Root(long x) => d[x] < 0 ? x : d[x] = (int)Root(d[x]);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Count(long x) => -d[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Calc(long x) => v[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Snapshot() => h.Clear();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Rollback()
        {
            while (h.Count > 0) Undo();
        }
    }
    class LIB_UnionFind : LIB_UnionFind<int>
    {
        public enum RootVtx { X, Y };
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(long n) : base(Enumerable.Repeat(0, (int)n), (x, y) => (RootVtx.X, x + y), (x, y) =>
        {
            if (x < y) return (x, y - x);
            else return (x - y, y);
        })
        { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        new private void Calc(long x) { }
    }
    class LIB_RedBlackTree
    {
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeMin() => new LIB_RedBlackTree<long, long, long>(long.MaxValue, long.MinValue + 100, Math.Min, (x, y, c) => y, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeMin() => new LIB_RedBlackTree<long, long, long>(long.MaxValue, 0, Math.Min, (x, y, c) => x + y, (x, y) => x + y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeMax() => new LIB_RedBlackTree<long, long, long>(long.MinValue, long.MaxValue - 100, Math.Max, (x, y, c) => y, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeMax() => new LIB_RedBlackTree<long, long, long>(long.MinValue, 0, Math.Max, (x, y, c) => x + y, (x, y) => x + y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeSum() => new LIB_RedBlackTree<long, long, long>(0, long.MaxValue, (x, y) => x + y, (x, y, c) => y * c, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeSum() => new LIB_RedBlackTree<long, long, long>(0, 0, (x, y) => x + y, (x, y, c) => x + y * c, (x, y) => x + y);
    }
    class LIB_RedBlackTree<Key, ValueT, ValueE> where ValueE : IEquatable<ValueE>
    {
        bool ope;
        class Node
        {
            public Node left;
            public Node right;
            public Key key;
            public ValueT val;
            public ValueT dat;
            public ValueE lazy;
            public bool isBlack;
            public int cnt;
            public bool needRecalc;
        }
        Func<ValueT, ValueT, ValueT> f;
        Func<ValueT, ValueE, int, ValueT> g;
        Func<ValueE, ValueE, ValueE> h;
        ValueT ti;
        ValueE ei;
        Comparison<Key> c;
        Node root;
        bool isNeedFix;
        Node lmax;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(ValueT ti, ValueE ei, Func<ValueT, ValueT, ValueT> f, Func<ValueT, ValueE, int, ValueT> g, Func<ValueE, ValueE, ValueE> h, Comparison<Key> c, bool ope = true)
        {
            this.ti = ti;
            this.ei = ei;
            this.f = f;
            this.g = g;
            this.h = h;
            this.c = c;
            this.ope = ope;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(ValueT ti, ValueE ei, Func<ValueT, ValueT, ValueT> f, Func<ValueT, ValueE, int, ValueT> g, Func<ValueE, ValueE, ValueE> h) : this(ti, ei, f, g, h, Comparer<Key>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        bool IsRed(Node n) => n != null && !n.isBlack;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        bool IsBlack(Node n) => n != null && n.isBlack;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        int Cnt(Node n) => n == null ? 0 : n.cnt;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Eval(Node n)
        {
            if (n == null || ei.Equals(n.lazy)) return;
            n.val = g(n.val, n.lazy, 1);
            if (!n.needRecalc) n.dat = g(n.dat, n.lazy, Cnt(n));
            if (n.left != null) n.left.lazy = h(n.left.lazy, n.lazy);
            if (n.right != null) n.right.lazy = h(n.right.lazy, n.lazy);
            n.lazy = ei;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Recalc(Node n)
        {
            if (n == null) return;
            Eval(n);
            if (!n.needRecalc) return;
            n.needRecalc = false;
            n.dat = n.val;
            if (n.left != null)
            {
                Recalc(n.left);
                n.dat = f(n.left.dat, n.dat);
            }
            if (n.right != null)
            {
                Recalc(n.right);
                n.dat = f(n.dat, n.right.dat);
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateL(Node n)
        {
            if (ope) { Eval(n); Eval(n.right); }
            Node m = n.right, t = m.left;
            m.left = n; n.right = t;
            n.cnt -= m.cnt - Cnt(t);
            m.cnt += n.cnt - Cnt(t);
            n.needRecalc = true; m.needRecalc = true;
            return m;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateR(Node n)
        {
            if (ope) { Eval(n); Eval(n.left); }
            Node m = n.left, t = m.right;
            m.right = n; n.left = t;
            n.cnt -= m.cnt - Cnt(t);
            m.cnt += n.cnt - Cnt(t);
            n.needRecalc = true; m.needRecalc = true;
            return m;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateLR(Node n)
        {
            n.left = RotateL(n.left);
            return RotateR(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateRL(Node n)
        {
            n.right = RotateR(n.right);
            return RotateL(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(Key key, ValueT val)
        {
            root = Add(root, key, val);
            root.isBlack = true;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Add(Node n, Key key, ValueT val)
        {
            if (n == null)
            {
                isNeedFix = true;
                return new Node() { key = key, val = val, dat = val, lazy = ei, cnt = 1 };
            }
            if (ope) Eval(n);
            if (c(key, n.key) < 0) n.left = Add(n.left, key, val);
            else n.right = Add(n.right, key, val);
            n.needRecalc = true;
            ++n.cnt;
            return Balance(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Balance(Node n)
        {
            if (!isNeedFix || !IsBlack(n)) return n;
            if (IsRed(n.left) && IsRed(n.left.left))
            {
                n = RotateR(n);
                n.left.isBlack = true;
            }
            else if (IsRed(n.left) && IsRed(n.left.right))
            {
                n = RotateLR(n);
                n.left.isBlack = true;
            }
            else if (IsRed(n.right) && IsRed(n.right.left))
            {
                n = RotateRL(n);
                n.right.isBlack = true;
            }
            else if (IsRed(n.right) && IsRed(n.right.right))
            {
                n = RotateL(n);
                n.right.isBlack = true;
            }
            else isNeedFix = false;
            return n;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(Key key)
        {
            root = Remove(root, key);
            if (root != null) root.isBlack = true;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Remove(Node n, Key key)
        {
            if (ope) Eval(n);
            --n.cnt;
            var r = c(key, n.key);
            if (r < 0)
            {
                n.left = Remove(n.left, key);
                n.needRecalc = true;
                return BalanceL(n);
            }
            if (r > 0)
            {
                n.right = Remove(n.right, key);
                n.needRecalc = true;
                return BalanceR(n);
            }
            if (n.left == null)
            {
                isNeedFix = n.isBlack;
                return n.right;
            }
            n.left = RemoveMax(n.left);
            n.key = lmax.key;
            n.val = lmax.val;
            n.needRecalc = true;
            return BalanceL(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RemoveMax(Node n)
        {
            if (ope) Eval(n);
            --n.cnt;
            if (n.right != null)
            {
                n.right = RemoveMax(n.right);
                n.needRecalc = true;
                return BalanceR(n);
            }
            lmax = n;
            isNeedFix = n.isBlack;
            return n.left;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node BalanceL(Node n)
        {
            if (!isNeedFix) return n;
            if (IsBlack(n.right) && IsRed(n.right.left))
            {
                var b = n.isBlack;
                n = RotateRL(n);
                n.isBlack = b;
                n.left.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.right) && IsRed(n.right.right))
            {
                var b = n.isBlack;
                n = RotateL(n);
                n.isBlack = b;
                n.right.isBlack = true;
                n.left.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.right))
            {
                isNeedFix = n.isBlack;
                n.isBlack = true;
                n.right.isBlack = false;
            }
            else
            {
                n = RotateL(n);
                n.isBlack = true;
                n.left.isBlack = false;
                n.left = BalanceL(n.left);
                isNeedFix = false;
            }
            return n;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node BalanceR(Node n)
        {
            if (!isNeedFix) return n;
            if (IsBlack(n.left) && IsRed(n.left.right))
            {
                var b = n.isBlack;
                n = RotateLR(n);
                n.isBlack = b; n.right.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.left) && IsRed(n.left.left))
            {
                var b = n.isBlack;
                n = RotateR(n);
                n.isBlack = b;
                n.left.isBlack = true;
                n.right.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.left))
            {
                isNeedFix = n.isBlack;
                n.isBlack = true;
                n.left.isBlack = false;
            }
            else
            {
                n = RotateR(n);
                n.isBlack = true;
                n.right.isBlack = false;
                n.right = BalanceR(n.right);
                isNeedFix = false;
            }
            return n;
        }
        public KeyValuePair<Key, ValueT> this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return At(root, i); }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        KeyValuePair<Key, ValueT> At(Node n, long i)
        {
            if (ope) Eval(n);
            if (n.left == null)
            {
                if (i == 0) return new KeyValuePair<Key, ValueT>(n.key, n.val);
                else return At(n.right, i - 1);
            }
            if (n.left.cnt == i) return new KeyValuePair<Key, ValueT>(n.key, n.val);
            if (n.left.cnt > i) return At(n.left, i);
            return At(n.right, i - n.left.cnt - 1);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(Key key)
        {
            var t = LowerBound(key);
            return t < Cnt(root) && c(At(root, t).Key, key) == 0;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(Key key) => UpperBound(root, key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        long UpperBound(Node n, Key key)
        {
            if (n == null) return 0;
            var r = c(key, n.key);
            if (r < 0) return UpperBound(n.left, key);
            return Cnt(n.left) + 1 + UpperBound(n.right, key);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(Key key) => LowerBound(root, key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        long LowerBound(Node n, Key key)
        {
            if (n == null) return 0;
            var r = c(key, n.key);
            if (r <= 0) return LowerBound(n.left, key);
            return Cnt(n.left) + 1 + LowerBound(n.right, key);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, ValueT> Min()
        {
            Node n = root.left, p = root;
            while (n != null)
            {
                p = n;
                if (ope) Eval(p);
                n = n.left;
            }
            return new KeyValuePair<Key, ValueT>(p.key, p.val);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, ValueT> Max()
        {
            Node n = root.right, p = root;
            while (n != null)
            {
                p = n;
                if (ope) Eval(p);
                n = n.right;
            }
            return new KeyValuePair<Key, ValueT>(p.key, p.val);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Update(long l, long r, ValueE val) => Update(root, l, r, val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Update(Node n, long l, long r, ValueE val)
        {
            if (n == null) return;
            Eval(n);
            n.needRecalc = true;
            var lc = Cnt(n.left);
            if (lc < l) Update(n.right, l - lc - 1, r - lc - 1, val);
            else if (r <= lc) Update(n.left, l, r, val);
            else if (l <= 0 && Cnt(n) <= r) n.lazy = val;
            else
            {
                n.val = g(n.val, val, 1);
                if (l < lc) Update(n.left, l, lc, val);
                if (lc + 1 < r) Update(n.right, 0, r - lc - 1, val);
            }
            return;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public ValueT Query(long l, long r) => Query(root, l, r);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        ValueT Query(Node n, long l, long r)
        {
            var v1 = ti; var v2 = ti; var v3 = ti;
            if (n == null) return ti;
            Eval(n);
            var lc = Cnt(n.left);
            if (lc < l) v3 = Query(n.right, l - lc - 1, r - lc - 1);
            else if (r <= lc) v1 = Query(n.left, l, r);
            else if (l <= 0 && Cnt(n) <= r)
            {
                Recalc(n);
                v2 = n.dat;
            }
            else
            {
                if (l < lc) v1 = Query(n.left, l, lc);
                if (lc + 1 < r) v3 = Query(n.right, 0, r - lc - 1);
                v2 = n.val;
            }
            return f(f(v1, v2), v3);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => root != null;
        public long Count => Cnt(root);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<KeyValuePair<Key, ValueT>> List() => L(root);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        IEnumerable<KeyValuePair<Key, ValueT>> L(Node n)
        {
            if (n == null) yield break;
            foreach (var i in L(n.left)) yield return i;
            yield return new KeyValuePair<Key, ValueT>(n.key, n.val);
            foreach (var i in L(n.right)) yield return i;
        }
    }
    class LIB_RedBlackTree<Key, Value>
    {
        LIB_RedBlackTree<Key, Value, int> tree;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(Comparison<Key> c) { tree = new LIB_RedBlackTree<Key, Value, int>(default(Value), 0, null, null, null, c, false); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree() : this(Comparer<Key>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(Key key, Value val) => tree.Add(key, val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(Key key) => tree.Remove(key);
        public KeyValuePair<Key, Value> this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return tree[i]; }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(Key key) => tree.ContainsKey(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(Key key) => tree.UpperBound(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(Key key) => tree.LowerBound(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, Value> Min() => tree.Min();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, Value> Max() => tree.Max();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => tree.Any();
        public long Count => tree.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<KeyValuePair<Key, Value>> List() => tree.List();
    }
    class LIB_RedBlackTree<T>
    {
        LIB_RedBlackTree<T, int, int> tree;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(Comparison<T> c) { tree = new LIB_RedBlackTree<T, int, int>(0, 0, null, null, null, c, false); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree() : this(Comparer<T>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(T val) => tree.Add(val, 0);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(T val) => tree.Remove(val);
        public T this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return tree[i].Key; }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(T val) => tree.ContainsKey(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(T val) => tree.UpperBound(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(T val) => tree.LowerBound(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Min() => tree.Min().Key;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Max() => tree.Max().Key;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => tree.Any();
        public long Count => tree.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<T> List() => tree.List().Select(e => e.Key);
    }
    class LIB_FastIO
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIO() { str = Console.OpenStandardInput(); }
        readonly Stream str;
        readonly byte[] buf = new byte[2048];
        int len, ptr;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        byte read()
        {
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 2048)) <= 0)
                {
                    return 0;
                }
            }
            return buf[ptr++];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = (ret << 3) + (ret << 1) + b - '0';
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
    class LIB_FastIODebug : LIB_FastIO
    {
        Queue<string> param = new Queue<string>();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIODebug() { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string Scan() => NextString();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override long Long() => long.Parse(NextString());
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override double Double() => double.Parse(NextString());
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ProblemD
    {
        static bool SAIKI = false;
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var n = (int)NN;
            var m = (int)NN;
            var q = (int)NN;
            var pList = NNList(n);
            var ab = Repeat(0, m).Select(_ => new { a = (int)NN - 1, b = (int)NN - 1 }).ToArray();
            var query = Repeat(0, q).Select(_ => new { t = (int)NN, param = (int)NN }).ToArray();
            var uf = new LIB_UnionFind<LIB_RedBlackTree<long>>(Range(0, n).Select(e =>
            {
                var ret = new LIB_RedBlackTree<long>();
                ret.Add(pList[e]);
                return ret;
            }), (x, y) =>
            {
                var rt = LIB_UnionFind.RootVtx.Y;
                if (x.Count > y.Count) { var t = x; x = y; y = t; rt = LIB_UnionFind.RootVtx.X; }
                foreach (var item in x.List()) y.Add(item);
                return (rt, y);
            }, (x, y) =>
            {
                foreach (var item in y.List().ToArray())
                {
                    if (x.ContainsKey(item)) x.Remove(item);
                    else y.Remove(item);
                }
                return (x, y);
            });
            var deleted = new bool[m];
            foreach (var item in query)
            {
                if (item.t == 2) deleted[item.param - 1] = true;
            }
            for (var i = 0; i < m; i++)
            {
                if (!deleted[i]) uf.Unite(ab[i].a, ab[i].b);
            }
            foreach (var item in query.Reverse())
            {
                if (item.t == 2) uf.Unite(ab[item.param - 1].a, ab[item.param - 1].b);
            }
            foreach (var item in query)
            {
                if (item.t == 1)
                {
                    var set = uf.Calc(item.param - 1);
                    var value = 0L;
                    if (set.Count > 0)
                    {
                        value = set.Max();
                        set.Remove(value);
                    }
                    Console.WriteLine(value);
                }
                else uf.Undo();
            }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static LIB_FastIO fastio = new LIB_FastIODebug();
        static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }
        static long NN => fastio.Long();
        static double ND => fastio.Double();
        static string NS => fastio.Scan();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);
        static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);
        static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
        static bool Chmax<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }
        static bool Chmin<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }
    }
}
namespace Library {
    class LIB_RedBlackTree
    {
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeMin() => new LIB_RedBlackTree<long, long, long>(long.MaxValue, long.MinValue + 100, Math.Min, (x, y, c) => y, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeMin() => new LIB_RedBlackTree<long, long, long>(long.MaxValue, 0, Math.Min, (x, y, c) => x + y, (x, y) => x + y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeMax() => new LIB_RedBlackTree<long, long, long>(long.MinValue, long.MaxValue - 100, Math.Max, (x, y, c) => y, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeMax() => new LIB_RedBlackTree<long, long, long>(long.MinValue, 0, Math.Max, (x, y, c) => x + y, (x, y) => x + y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeSum() => new LIB_RedBlackTree<long, long, long>(0, long.MaxValue, (x, y) => x + y, (x, y, c) => y * c, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeSum() => new LIB_RedBlackTree<long, long, long>(0, 0, (x, y) => x + y, (x, y, c) => x + y * c, (x, y) => x + y);
    }
    class LIB_RedBlackTree<Key, ValueT, ValueE> where ValueE : IEquatable<ValueE>
    {
        bool ope;
        class Node
        {
            public Node left;
            public Node right;
            public Key key;
            public ValueT val;
            public ValueT dat;
            public ValueE lazy;
            public bool isBlack;
            public int cnt;
            public bool needRecalc;
        }
        Func<ValueT, ValueT, ValueT> f;
        Func<ValueT, ValueE, int, ValueT> g;
        Func<ValueE, ValueE, ValueE> h;
        ValueT ti;
        ValueE ei;
        Comparison<Key> c;
        Node root;
        bool isNeedFix;
        Node lmax;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(ValueT ti, ValueE ei, Func<ValueT, ValueT, ValueT> f, Func<ValueT, ValueE, int, ValueT> g, Func<ValueE, ValueE, ValueE> h, Comparison<Key> c, bool ope = true)
        {
            this.ti = ti;
            this.ei = ei;
            this.f = f;
            this.g = g;
            this.h = h;
            this.c = c;
            this.ope = ope;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(ValueT ti, ValueE ei, Func<ValueT, ValueT, ValueT> f, Func<ValueT, ValueE, int, ValueT> g, Func<ValueE, ValueE, ValueE> h) : this(ti, ei, f, g, h, Comparer<Key>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        bool IsRed(Node n) => n != null && !n.isBlack;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        bool IsBlack(Node n) => n != null && n.isBlack;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        int Cnt(Node n) => n == null ? 0 : n.cnt;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Eval(Node n)
        {
            if (n == null || ei.Equals(n.lazy)) return;
            n.val = g(n.val, n.lazy, 1);
            if (!n.needRecalc) n.dat = g(n.dat, n.lazy, Cnt(n));
            if (n.left != null) n.left.lazy = h(n.left.lazy, n.lazy);
            if (n.right != null) n.right.lazy = h(n.right.lazy, n.lazy);
            n.lazy = ei;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Recalc(Node n)
        {
            if (n == null) return;
            Eval(n);
            if (!n.needRecalc) return;
            n.needRecalc = false;
            n.dat = n.val;
            if (n.left != null)
            {
                Recalc(n.left);
                n.dat = f(n.left.dat, n.dat);
            }
            if (n.right != null)
            {
                Recalc(n.right);
                n.dat = f(n.dat, n.right.dat);
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateL(Node n)
        {
            if (ope) { Eval(n); Eval(n.right); }
            Node m = n.right, t = m.left;
            m.left = n; n.right = t;
            n.cnt -= m.cnt - Cnt(t);
            m.cnt += n.cnt - Cnt(t);
            n.needRecalc = true; m.needRecalc = true;
            return m;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateR(Node n)
        {
            if (ope) { Eval(n); Eval(n.left); }
            Node m = n.left, t = m.right;
            m.right = n; n.left = t;
            n.cnt -= m.cnt - Cnt(t);
            m.cnt += n.cnt - Cnt(t);
            n.needRecalc = true; m.needRecalc = true;
            return m;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateLR(Node n)
        {
            n.left = RotateL(n.left);
            return RotateR(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateRL(Node n)
        {
            n.right = RotateR(n.right);
            return RotateL(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(Key key, ValueT val)
        {
            root = Add(root, key, val);
            root.isBlack = true;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Add(Node n, Key key, ValueT val)
        {
            if (n == null)
            {
                isNeedFix = true;
                return new Node() { key = key, val = val, dat = val, lazy = ei, cnt = 1 };
            }
            if (ope) Eval(n);
            if (c(key, n.key) < 0) n.left = Add(n.left, key, val);
            else n.right = Add(n.right, key, val);
            n.needRecalc = true;
            ++n.cnt;
            return Balance(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Balance(Node n)
        {
            if (!isNeedFix || !IsBlack(n)) return n;
            if (IsRed(n.left) && IsRed(n.left.left))
            {
                n = RotateR(n);
                n.left.isBlack = true;
            }
            else if (IsRed(n.left) && IsRed(n.left.right))
            {
                n = RotateLR(n);
                n.left.isBlack = true;
            }
            else if (IsRed(n.right) && IsRed(n.right.left))
            {
                n = RotateRL(n);
                n.right.isBlack = true;
            }
            else if (IsRed(n.right) && IsRed(n.right.right))
            {
                n = RotateL(n);
                n.right.isBlack = true;
            }
            else isNeedFix = false;
            return n;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(Key key)
        {
            root = Remove(root, key);
            if (root != null) root.isBlack = true;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Remove(Node n, Key key)
        {
            if (ope) Eval(n);
            --n.cnt;
            var r = c(key, n.key);
            if (r < 0)
            {
                n.left = Remove(n.left, key);
                n.needRecalc = true;
                return BalanceL(n);
            }
            if (r > 0)
            {
                n.right = Remove(n.right, key);
                n.needRecalc = true;
                return BalanceR(n);
            }
            if (n.left == null)
            {
                isNeedFix = n.isBlack;
                return n.right;
            }
            n.left = RemoveMax(n.left);
            n.key = lmax.key;
            n.val = lmax.val;
            n.needRecalc = true;
            return BalanceL(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RemoveMax(Node n)
        {
            if (ope) Eval(n);
            --n.cnt;
            if (n.right != null)
            {
                n.right = RemoveMax(n.right);
                n.needRecalc = true;
                return BalanceR(n);
            }
            lmax = n;
            isNeedFix = n.isBlack;
            return n.left;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node BalanceL(Node n)
        {
            if (!isNeedFix) return n;
            if (IsBlack(n.right) && IsRed(n.right.left))
            {
                var b = n.isBlack;
                n = RotateRL(n);
                n.isBlack = b;
                n.left.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.right) && IsRed(n.right.right))
            {
                var b = n.isBlack;
                n = RotateL(n);
                n.isBlack = b;
                n.right.isBlack = true;
                n.left.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.right))
            {
                isNeedFix = n.isBlack;
                n.isBlack = true;
                n.right.isBlack = false;
            }
            else
            {
                n = RotateL(n);
                n.isBlack = true;
                n.left.isBlack = false;
                n.left = BalanceL(n.left);
                isNeedFix = false;
            }
            return n;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node BalanceR(Node n)
        {
            if (!isNeedFix) return n;
            if (IsBlack(n.left) && IsRed(n.left.right))
            {
                var b = n.isBlack;
                n = RotateLR(n);
                n.isBlack = b; n.right.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.left) && IsRed(n.left.left))
            {
                var b = n.isBlack;
                n = RotateR(n);
                n.isBlack = b;
                n.left.isBlack = true;
                n.right.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.left))
            {
                isNeedFix = n.isBlack;
                n.isBlack = true;
                n.left.isBlack = false;
            }
            else
            {
                n = RotateR(n);
                n.isBlack = true;
                n.right.isBlack = false;
                n.right = BalanceR(n.right);
                isNeedFix = false;
            }
            return n;
        }
        public KeyValuePair<Key, ValueT> this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return At(root, i); }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        KeyValuePair<Key, ValueT> At(Node n, long i)
        {
            if (ope) Eval(n);
            if (n.left == null)
            {
                if (i == 0) return new KeyValuePair<Key, ValueT>(n.key, n.val);
                else return At(n.right, i - 1);
            }
            if (n.left.cnt == i) return new KeyValuePair<Key, ValueT>(n.key, n.val);
            if (n.left.cnt > i) return At(n.left, i);
            return At(n.right, i - n.left.cnt - 1);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(Key key)
        {
            var t = LowerBound(key);
            return t < Cnt(root) && c(At(root, t).Key, key) == 0;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(Key key) => UpperBound(root, key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        long UpperBound(Node n, Key key)
        {
            if (n == null) return 0;
            var r = c(key, n.key);
            if (r < 0) return UpperBound(n.left, key);
            return Cnt(n.left) + 1 + UpperBound(n.right, key);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(Key key) => LowerBound(root, key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        long LowerBound(Node n, Key key)
        {
            if (n == null) return 0;
            var r = c(key, n.key);
            if (r <= 0) return LowerBound(n.left, key);
            return Cnt(n.left) + 1 + LowerBound(n.right, key);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, ValueT> Min()
        {
            Node n = root.left, p = root;
            while (n != null)
            {
                p = n;
                if (ope) Eval(p);
                n = n.left;
            }
            return new KeyValuePair<Key, ValueT>(p.key, p.val);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, ValueT> Max()
        {
            Node n = root.right, p = root;
            while (n != null)
            {
                p = n;
                if (ope) Eval(p);
                n = n.right;
            }
            return new KeyValuePair<Key, ValueT>(p.key, p.val);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Update(long l, long r, ValueE val) => Update(root, l, r, val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Update(Node n, long l, long r, ValueE val)
        {
            if (n == null) return;
            Eval(n);
            n.needRecalc = true;
            var lc = Cnt(n.left);
            if (lc < l) Update(n.right, l - lc - 1, r - lc - 1, val);
            else if (r <= lc) Update(n.left, l, r, val);
            else if (l <= 0 && Cnt(n) <= r) n.lazy = val;
            else
            {
                n.val = g(n.val, val, 1);
                if (l < lc) Update(n.left, l, lc, val);
                if (lc + 1 < r) Update(n.right, 0, r - lc - 1, val);
            }
            return;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public ValueT Query(long l, long r) => Query(root, l, r);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        ValueT Query(Node n, long l, long r)
        {
            var v1 = ti; var v2 = ti; var v3 = ti;
            if (n == null) return ti;
            Eval(n);
            var lc = Cnt(n.left);
            if (lc < l) v3 = Query(n.right, l - lc - 1, r - lc - 1);
            else if (r <= lc) v1 = Query(n.left, l, r);
            else if (l <= 0 && Cnt(n) <= r)
            {
                Recalc(n);
                v2 = n.dat;
            }
            else
            {
                if (l < lc) v1 = Query(n.left, l, lc);
                if (lc + 1 < r) v3 = Query(n.right, 0, r - lc - 1);
                v2 = n.val;
            }
            return f(f(v1, v2), v3);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => root != null;
        public long Count => Cnt(root);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<KeyValuePair<Key, ValueT>> List() => L(root);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        IEnumerable<KeyValuePair<Key, ValueT>> L(Node n)
        {
            if (n == null) yield break;
            foreach (var i in L(n.left)) yield return i;
            yield return new KeyValuePair<Key, ValueT>(n.key, n.val);
            foreach (var i in L(n.right)) yield return i;
        }
    }
    class LIB_RedBlackTree<Key, Value>
    {
        LIB_RedBlackTree<Key, Value, int> tree;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(Comparison<Key> c) { tree = new LIB_RedBlackTree<Key, Value, int>(default(Value), 0, null, null, null, c, false); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree() : this(Comparer<Key>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(Key key, Value val) => tree.Add(key, val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(Key key) => tree.Remove(key);
        public KeyValuePair<Key, Value> this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return tree[i]; }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(Key key) => tree.ContainsKey(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(Key key) => tree.UpperBound(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(Key key) => tree.LowerBound(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, Value> Min() => tree.Min();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, Value> Max() => tree.Max();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => tree.Any();
        public long Count => tree.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<KeyValuePair<Key, Value>> List() => tree.List();
    }
    class LIB_RedBlackTree<T>
    {
        LIB_RedBlackTree<T, int, int> tree;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(Comparison<T> c) { tree = new LIB_RedBlackTree<T, int, int>(0, 0, null, null, null, c, false); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree() : this(Comparer<T>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(T val) => tree.Add(val, 0);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(T val) => tree.Remove(val);
        public T this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return tree[i].Key; }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(T val) => tree.ContainsKey(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(T val) => tree.UpperBound(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(T val) => tree.LowerBound(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Min() => tree.Min().Key;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Max() => tree.Max().Key;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => tree.Any();
        public long Count => tree.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<T> List() => tree.List().Select(e => e.Key);
    }
    class LIB_UnionFind<T>
    {
        int[] d;
        Stack<(int, int)> h;
        T[] v;
        Func<T, T, (LIB_UnionFind.RootVtx, T)> f;
        Func<T, T, (T, T)> rf;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(IEnumerable<T> s, Func<T, T, (LIB_UnionFind.RootVtx, T)> func, Func<T, T, (T, T)> revFunc)
        {
            v = s.ToArray();
            d = Enumerable.Repeat(-1, v.Length).ToArray();
            f = func;
            rf = revFunc;
            h = new Stack<(int, int)>();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Unite(long x, long y)
        {
            x = Root(x);
            y = Root(y);
            if (x != y)
            {
                var (root, value) = f(v[x], v[y]);
                if (root == LIB_UnionFind.RootVtx.X)
                {
                    h.Push(((int)y, d[y]));
                    h.Push(((int)x, d[x]));
                    d[x] = d[x] + d[y];
                    d[y] = (int)x;
                    v[x] = value;
                }
                else
                {
                    h.Push(((int)x, d[x]));
                    h.Push(((int)y, d[y]));
                    d[y] = d[x] + d[y];
                    d[x] = (int)y;
                    v[y] = value;
                }
            }
            else
            {
                h.Push(((int)y, d[y]));
                h.Push(((int)x, d[x]));
            }
            return x != y;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Undo()
        {
            var pop1 = h.Pop();
            var pop2 = h.Pop();
            if (pop1.Item1 == pop2.Item1) return;
            d[pop1.Item1] = pop1.Item2;
            d[pop2.Item1] = pop2.Item2;
            (v[pop1.Item1], v[pop2.Item1]) = rf(v[pop1.Item1], v[pop2.Item1]);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool IsSame(long x, long y) => Root(x) == Root(y);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Root(long x) => d[x] < 0 ? x : d[x] = (int)Root(d[x]);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Count(long x) => -d[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Calc(long x) => v[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Snapshot() => h.Clear();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Rollback()
        {
            while (h.Count > 0) Undo();
        }
    }
    class LIB_UnionFind : LIB_UnionFind<int>
    {
        public enum RootVtx { X, Y };
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(long n) : base(Enumerable.Repeat(0, (int)n), (x, y) => (RootVtx.X, x + y), (x, y) =>
        {
            if (x < y) return (x, y - x);
            else return (x - y, y);
        })
        { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        new private void Calc(long x) { }
    }
    class LIB_FastIO
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIO() { str = Console.OpenStandardInput(); }
        readonly Stream str;
        readonly byte[] buf = new byte[2048];
        int len, ptr;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        byte read()
        {
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 2048)) <= 0)
                {
                    return 0;
                }
            }
            return buf[ptr++];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = (ret << 3) + (ret << 1) + b - '0';
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
    class LIB_FastIODebug : LIB_FastIO
    {
        Queue<string> param = new Queue<string>();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIODebug() { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string Scan() => NextString();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override long Long() => long.Parse(NextString());
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override double Double() => double.Parse(NextString());
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ProblemD
    {
        static bool SAIKI = false;
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var n = (int)NN;
            var m = (int)NN;
            var q = (int)NN;
            var pList = NNList(n);
            var ab = Repeat(0, m).Select(_ => new { a = (int)NN - 1, b = (int)NN - 1 }).ToArray();
            var query = Repeat(0, q).Select(_ => new { t = (int)NN, param = (int)NN }).ToArray();
            var uf = new LIB_UnionFind<LIB_RedBlackTree<long>>(Range(0, n).Select(e =>
            {
                var ret = new LIB_RedBlackTree<long>();
                ret.Add(pList[e]);
                return ret;
            }), (x, y) =>
            {
                var rt = LIB_UnionFind.RootVtx.X;
                if (x.Count > y.Count) { var t = x; x = y; y = t; rt = LIB_UnionFind.RootVtx.Y; }
                foreach (var item in y.List()) x.Add(item);
                return (rt, x);
            }, (x, y) =>
            {
                foreach (var item in y.List().ToArray())
                {
                    if (x.ContainsKey(item)) x.Remove(item);
                    else y.Remove(item);
                }
                return (x, y);
            });
            var deleted = new bool[m];
            foreach (var item in query)
            {
                if (item.t == 2) deleted[item.param - 1] = true;
            }
            for (var i = 0; i < m; i++)
            {
                if (!deleted[i]) uf.Unite(ab[i].a, ab[i].b);
            }
            foreach (var item in query.Reverse())
            {
                if (item.t == 2) uf.Unite(ab[item.param - 1].a, ab[item.param - 1].b);
            }
            foreach (var item in query)
            {
                if (item.t == 1)
                {
                    var set = uf.Calc(item.param - 1);
                    var value = 0L;
                    if (set.Count > 0)
                    {
                        value = set.Max();
                        set.Remove(value);
                    }
                    Console.WriteLine(value);
                }
                else uf.Undo();
            }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static LIB_FastIO fastio = new LIB_FastIODebug();
        static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }
        static long NN => fastio.Long();
        static double ND => fastio.Double();
        static string NS => fastio.Scan();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);
        static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);
        static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
        static bool Chmax<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }
        static bool Chmin<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }
    }
}
namespace Library {
    class LIB_FastIO
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIO() { str = Console.OpenStandardInput(); }
        readonly Stream str;
        readonly byte[] buf = new byte[2048];
        int len, ptr;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        byte read()
        {
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 2048)) <= 0)
                {
                    return 0;
                }
            }
            return buf[ptr++];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = (ret << 3) + (ret << 1) + b - '0';
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
    class LIB_FastIODebug : LIB_FastIO
    {
        Queue<string> param = new Queue<string>();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIODebug() { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string Scan() => NextString();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override long Long() => long.Parse(NextString());
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override double Double() => double.Parse(NextString());
    }
    class LIB_RedBlackTree
    {
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeMin() => new LIB_RedBlackTree<long, long, long>(long.MaxValue, long.MinValue + 100, Math.Min, (x, y, c) => y, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeMin() => new LIB_RedBlackTree<long, long, long>(long.MaxValue, 0, Math.Min, (x, y, c) => x + y, (x, y) => x + y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeMax() => new LIB_RedBlackTree<long, long, long>(long.MinValue, long.MaxValue - 100, Math.Max, (x, y, c) => y, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeMax() => new LIB_RedBlackTree<long, long, long>(long.MinValue, 0, Math.Max, (x, y, c) => x + y, (x, y) => x + y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeSum() => new LIB_RedBlackTree<long, long, long>(0, long.MaxValue, (x, y) => x + y, (x, y, c) => y * c, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeSum() => new LIB_RedBlackTree<long, long, long>(0, 0, (x, y) => x + y, (x, y, c) => x + y * c, (x, y) => x + y);
    }
    class LIB_RedBlackTree<Key, ValueT, ValueE> where ValueE : IEquatable<ValueE>
    {
        bool ope;
        class Node
        {
            public Node left;
            public Node right;
            public Key key;
            public ValueT val;
            public ValueT dat;
            public ValueE lazy;
            public bool isBlack;
            public int cnt;
            public bool needRecalc;
        }
        Func<ValueT, ValueT, ValueT> f;
        Func<ValueT, ValueE, int, ValueT> g;
        Func<ValueE, ValueE, ValueE> h;
        ValueT ti;
        ValueE ei;
        Comparison<Key> c;
        Node root;
        bool isNeedFix;
        Node lmax;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(ValueT ti, ValueE ei, Func<ValueT, ValueT, ValueT> f, Func<ValueT, ValueE, int, ValueT> g, Func<ValueE, ValueE, ValueE> h, Comparison<Key> c, bool ope = true)
        {
            this.ti = ti;
            this.ei = ei;
            this.f = f;
            this.g = g;
            this.h = h;
            this.c = c;
            this.ope = ope;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(ValueT ti, ValueE ei, Func<ValueT, ValueT, ValueT> f, Func<ValueT, ValueE, int, ValueT> g, Func<ValueE, ValueE, ValueE> h) : this(ti, ei, f, g, h, Comparer<Key>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        bool IsRed(Node n) => n != null && !n.isBlack;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        bool IsBlack(Node n) => n != null && n.isBlack;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        int Cnt(Node n) => n == null ? 0 : n.cnt;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Eval(Node n)
        {
            if (n == null || ei.Equals(n.lazy)) return;
            n.val = g(n.val, n.lazy, 1);
            if (!n.needRecalc) n.dat = g(n.dat, n.lazy, Cnt(n));
            if (n.left != null) n.left.lazy = h(n.left.lazy, n.lazy);
            if (n.right != null) n.right.lazy = h(n.right.lazy, n.lazy);
            n.lazy = ei;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Recalc(Node n)
        {
            if (n == null) return;
            Eval(n);
            if (!n.needRecalc) return;
            n.needRecalc = false;
            n.dat = n.val;
            if (n.left != null)
            {
                Recalc(n.left);
                n.dat = f(n.left.dat, n.dat);
            }
            if (n.right != null)
            {
                Recalc(n.right);
                n.dat = f(n.dat, n.right.dat);
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateL(Node n)
        {
            if (ope) { Eval(n); Eval(n.right); }
            Node m = n.right, t = m.left;
            m.left = n; n.right = t;
            n.cnt -= m.cnt - Cnt(t);
            m.cnt += n.cnt - Cnt(t);
            n.needRecalc = true; m.needRecalc = true;
            return m;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateR(Node n)
        {
            if (ope) { Eval(n); Eval(n.left); }
            Node m = n.left, t = m.right;
            m.right = n; n.left = t;
            n.cnt -= m.cnt - Cnt(t);
            m.cnt += n.cnt - Cnt(t);
            n.needRecalc = true; m.needRecalc = true;
            return m;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateLR(Node n)
        {
            n.left = RotateL(n.left);
            return RotateR(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateRL(Node n)
        {
            n.right = RotateR(n.right);
            return RotateL(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(Key key, ValueT val)
        {
            root = Add(root, key, val);
            root.isBlack = true;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Add(Node n, Key key, ValueT val)
        {
            if (n == null)
            {
                isNeedFix = true;
                return new Node() { key = key, val = val, dat = val, lazy = ei, cnt = 1 };
            }
            if (ope) Eval(n);
            if (c(key, n.key) < 0) n.left = Add(n.left, key, val);
            else n.right = Add(n.right, key, val);
            n.needRecalc = true;
            ++n.cnt;
            return Balance(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Balance(Node n)
        {
            if (!isNeedFix || !IsBlack(n)) return n;
            if (IsRed(n.left) && IsRed(n.left.left))
            {
                n = RotateR(n);
                n.left.isBlack = true;
            }
            else if (IsRed(n.left) && IsRed(n.left.right))
            {
                n = RotateLR(n);
                n.left.isBlack = true;
            }
            else if (IsRed(n.right) && IsRed(n.right.left))
            {
                n = RotateRL(n);
                n.right.isBlack = true;
            }
            else if (IsRed(n.right) && IsRed(n.right.right))
            {
                n = RotateL(n);
                n.right.isBlack = true;
            }
            else isNeedFix = false;
            return n;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(Key key)
        {
            root = Remove(root, key);
            if (root != null) root.isBlack = true;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Remove(Node n, Key key)
        {
            if (ope) Eval(n);
            --n.cnt;
            var r = c(key, n.key);
            if (r < 0)
            {
                n.left = Remove(n.left, key);
                n.needRecalc = true;
                return BalanceL(n);
            }
            if (r > 0)
            {
                n.right = Remove(n.right, key);
                n.needRecalc = true;
                return BalanceR(n);
            }
            if (n.left == null)
            {
                isNeedFix = n.isBlack;
                return n.right;
            }
            n.left = RemoveMax(n.left);
            n.key = lmax.key;
            n.val = lmax.val;
            n.needRecalc = true;
            return BalanceL(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RemoveMax(Node n)
        {
            if (ope) Eval(n);
            --n.cnt;
            if (n.right != null)
            {
                n.right = RemoveMax(n.right);
                n.needRecalc = true;
                return BalanceR(n);
            }
            lmax = n;
            isNeedFix = n.isBlack;
            return n.left;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node BalanceL(Node n)
        {
            if (!isNeedFix) return n;
            if (IsBlack(n.right) && IsRed(n.right.left))
            {
                var b = n.isBlack;
                n = RotateRL(n);
                n.isBlack = b;
                n.left.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.right) && IsRed(n.right.right))
            {
                var b = n.isBlack;
                n = RotateL(n);
                n.isBlack = b;
                n.right.isBlack = true;
                n.left.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.right))
            {
                isNeedFix = n.isBlack;
                n.isBlack = true;
                n.right.isBlack = false;
            }
            else
            {
                n = RotateL(n);
                n.isBlack = true;
                n.left.isBlack = false;
                n.left = BalanceL(n.left);
                isNeedFix = false;
            }
            return n;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node BalanceR(Node n)
        {
            if (!isNeedFix) return n;
            if (IsBlack(n.left) && IsRed(n.left.right))
            {
                var b = n.isBlack;
                n = RotateLR(n);
                n.isBlack = b; n.right.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.left) && IsRed(n.left.left))
            {
                var b = n.isBlack;
                n = RotateR(n);
                n.isBlack = b;
                n.left.isBlack = true;
                n.right.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.left))
            {
                isNeedFix = n.isBlack;
                n.isBlack = true;
                n.left.isBlack = false;
            }
            else
            {
                n = RotateR(n);
                n.isBlack = true;
                n.right.isBlack = false;
                n.right = BalanceR(n.right);
                isNeedFix = false;
            }
            return n;
        }
        public KeyValuePair<Key, ValueT> this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return At(root, i); }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        KeyValuePair<Key, ValueT> At(Node n, long i)
        {
            if (ope) Eval(n);
            if (n.left == null)
            {
                if (i == 0) return new KeyValuePair<Key, ValueT>(n.key, n.val);
                else return At(n.right, i - 1);
            }
            if (n.left.cnt == i) return new KeyValuePair<Key, ValueT>(n.key, n.val);
            if (n.left.cnt > i) return At(n.left, i);
            return At(n.right, i - n.left.cnt - 1);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(Key key)
        {
            var t = LowerBound(key);
            return t < Cnt(root) && c(At(root, t).Key, key) == 0;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(Key key) => UpperBound(root, key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        long UpperBound(Node n, Key key)
        {
            if (n == null) return 0;
            var r = c(key, n.key);
            if (r < 0) return UpperBound(n.left, key);
            return Cnt(n.left) + 1 + UpperBound(n.right, key);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(Key key) => LowerBound(root, key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        long LowerBound(Node n, Key key)
        {
            if (n == null) return 0;
            var r = c(key, n.key);
            if (r <= 0) return LowerBound(n.left, key);
            return Cnt(n.left) + 1 + LowerBound(n.right, key);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, ValueT> Min()
        {
            Node n = root.left, p = root;
            while (n != null)
            {
                p = n;
                if (ope) Eval(p);
                n = n.left;
            }
            return new KeyValuePair<Key, ValueT>(p.key, p.val);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, ValueT> Max()
        {
            Node n = root.right, p = root;
            while (n != null)
            {
                p = n;
                if (ope) Eval(p);
                n = n.right;
            }
            return new KeyValuePair<Key, ValueT>(p.key, p.val);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Update(long l, long r, ValueE val) => Update(root, l, r, val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Update(Node n, long l, long r, ValueE val)
        {
            if (n == null) return;
            Eval(n);
            n.needRecalc = true;
            var lc = Cnt(n.left);
            if (lc < l) Update(n.right, l - lc - 1, r - lc - 1, val);
            else if (r <= lc) Update(n.left, l, r, val);
            else if (l <= 0 && Cnt(n) <= r) n.lazy = val;
            else
            {
                n.val = g(n.val, val, 1);
                if (l < lc) Update(n.left, l, lc, val);
                if (lc + 1 < r) Update(n.right, 0, r - lc - 1, val);
            }
            return;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public ValueT Query(long l, long r) => Query(root, l, r);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        ValueT Query(Node n, long l, long r)
        {
            var v1 = ti; var v2 = ti; var v3 = ti;
            if (n == null) return ti;
            Eval(n);
            var lc = Cnt(n.left);
            if (lc < l) v3 = Query(n.right, l - lc - 1, r - lc - 1);
            else if (r <= lc) v1 = Query(n.left, l, r);
            else if (l <= 0 && Cnt(n) <= r)
            {
                Recalc(n);
                v2 = n.dat;
            }
            else
            {
                if (l < lc) v1 = Query(n.left, l, lc);
                if (lc + 1 < r) v3 = Query(n.right, 0, r - lc - 1);
                v2 = n.val;
            }
            return f(f(v1, v2), v3);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => root != null;
        public long Count => Cnt(root);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<KeyValuePair<Key, ValueT>> List() => L(root);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        IEnumerable<KeyValuePair<Key, ValueT>> L(Node n)
        {
            if (n == null) yield break;
            foreach (var i in L(n.left)) yield return i;
            yield return new KeyValuePair<Key, ValueT>(n.key, n.val);
            foreach (var i in L(n.right)) yield return i;
        }
    }
    class LIB_RedBlackTree<Key, Value>
    {
        LIB_RedBlackTree<Key, Value, int> tree;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(Comparison<Key> c) { tree = new LIB_RedBlackTree<Key, Value, int>(default(Value), 0, null, null, null, c, false); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree() : this(Comparer<Key>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(Key key, Value val) => tree.Add(key, val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(Key key) => tree.Remove(key);
        public KeyValuePair<Key, Value> this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return tree[i]; }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(Key key) => tree.ContainsKey(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(Key key) => tree.UpperBound(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(Key key) => tree.LowerBound(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, Value> Min() => tree.Min();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, Value> Max() => tree.Max();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => tree.Any();
        public long Count => tree.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<KeyValuePair<Key, Value>> List() => tree.List();
    }
    class LIB_RedBlackTree<T>
    {
        LIB_RedBlackTree<T, int, int> tree;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(Comparison<T> c) { tree = new LIB_RedBlackTree<T, int, int>(0, 0, null, null, null, c, false); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree() : this(Comparer<T>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(T val) => tree.Add(val, 0);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(T val) => tree.Remove(val);
        public T this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return tree[i].Key; }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(T val) => tree.ContainsKey(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(T val) => tree.UpperBound(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(T val) => tree.LowerBound(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Min() => tree.Min().Key;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Max() => tree.Max().Key;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => tree.Any();
        public long Count => tree.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<T> List() => tree.List().Select(e => e.Key);
    }
    class LIB_UnionFind<T>
    {
        int[] d;
        Stack<(int, int)> h;
        T[] v;
        Func<T, T, (LIB_UnionFind.RootVtx, T)> f;
        Func<T, T, (T, T)> rf;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(IEnumerable<T> s, Func<T, T, (LIB_UnionFind.RootVtx, T)> func, Func<T, T, (T, T)> revFunc)
        {
            v = s.ToArray();
            d = Enumerable.Repeat(-1, v.Length).ToArray();
            f = func;
            rf = revFunc;
            h = new Stack<(int, int)>();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Unite(long x, long y)
        {
            x = Root(x);
            y = Root(y);
            if (x != y)
            {
                var (root, value) = f(v[x], v[y]);
                if (root == LIB_UnionFind.RootVtx.X)
                {
                    h.Push(((int)y, d[y]));
                    h.Push(((int)x, d[x]));
                    d[x] = d[x] + d[y];
                    d[y] = (int)x;
                    v[x] = value;
                }
                else
                {
                    h.Push(((int)x, d[x]));
                    h.Push(((int)y, d[y]));
                    d[y] = d[x] + d[y];
                    d[x] = (int)y;
                    v[y] = value;
                }
            }
            else
            {
                h.Push(((int)y, d[y]));
                h.Push(((int)x, d[x]));
            }
            return x != y;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Undo()
        {
            var pop1 = h.Pop();
            var pop2 = h.Pop();
            if (pop1.Item1 == pop2.Item1) return;
            d[pop1.Item1] = pop1.Item2;
            d[pop2.Item1] = pop2.Item2;
            (v[pop1.Item1], v[pop2.Item1]) = rf(v[pop1.Item1], v[pop2.Item1]);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool IsSame(long x, long y) => Root(x) == Root(y);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Root(long x) => d[x] < 0 ? x : d[x] = (int)Root(d[x]);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Count(long x) => -d[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Calc(long x) => v[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Snapshot() => h.Clear();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Rollback()
        {
            while (h.Count > 0) Undo();
        }
    }
    class LIB_UnionFind : LIB_UnionFind<int>
    {
        public enum RootVtx { X, Y };
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(long n) : base(Enumerable.Repeat(0, (int)n), (x, y) => (RootVtx.X, x + y), (x, y) =>
        {
            if (x < y) return (x, y - x);
            else return (x - y, y);
        })
        { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        new private void Calc(long x) { }
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ProblemD
    {
        static bool SAIKI = false;
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var n = (int)NN;
            var m = (int)NN;
            var q = (int)NN;
            var pList = NNList(n);
            var ab = Repeat(0, m).Select(_ => new { a = (int)NN - 1, b = (int)NN - 1 }).ToArray();
            var query = Repeat(0, q).Select(_ => new { t = (int)NN, param = (int)NN }).ToArray();
            var uf = new LIB_UnionFind<LIB_RedBlackTree<long>>(Range(0, n).Select(e =>
            {
                var ret = new LIB_RedBlackTree<long>();
                ret.Add(pList[e]);
                return ret;
            }), (x, y) =>
            {
                if (x.Count > y.Count) { var t = x; x = y; y = t; }
                foreach (var item in x.List()) y.Add(item);
                return y;
            }, (x, y) =>
            {
                var rev = false;
                if (x.Count > y.Count)
                {
                    var t = x; x = y; y = t;
                    rev = true;
                }
                foreach (var item in x.List().ToArray())
                {
                    if (y.ContainsKey(item)) y.Remove(item);
                }
                if (rev) return (y, x);
                else return (x, y);
            });
            var deleted = new bool[m];
            foreach (var item in query)
            {
                if (item.t == 2) deleted[item.param - 1] = true;
            }
            for (var i = 0; i < m; i++)
            {
                if (!deleted[i]) uf.Unite(ab[i].a, ab[i].b);
            }
            foreach (var item in query.Reverse())
            {
                if (item.t == 2) uf.Unite(ab[item.param - 1].a, ab[item.param - 1].b);
            }
            foreach (var item in query)
            {
                if (item.t == 1)
                {
                    var set = uf.Calc(item.param - 1);
                    var value = 0L;
                    if (set.Count > 0)
                    {
                        value = set.Max();
                        set.Remove(value);
                    }
                    Console.WriteLine(value);
                }
                else uf.Undo();
            }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static LIB_FastIO fastio = new LIB_FastIODebug();
        static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }
        static long NN => fastio.Long();
        static double ND => fastio.Double();
        static string NS => fastio.Scan();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);
        static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);
        static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
        static bool Chmax<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }
        static bool Chmin<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }
    }
}
namespace Library {
    class LIB_FastIO
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIO() { str = Console.OpenStandardInput(); }
        readonly Stream str;
        readonly byte[] buf = new byte[2048];
        int len, ptr;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        byte read()
        {
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 2048)) <= 0)
                {
                    return 0;
                }
            }
            return buf[ptr++];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = (ret << 3) + (ret << 1) + b - '0';
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
    class LIB_FastIODebug : LIB_FastIO
    {
        Queue<string> param = new Queue<string>();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIODebug() { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string Scan() => NextString();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override long Long() => long.Parse(NextString());
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override double Double() => double.Parse(NextString());
    }
    class LIB_RedBlackTree
    {
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeMin() => new LIB_RedBlackTree<long, long, long>(long.MaxValue, long.MinValue + 100, Math.Min, (x, y, c) => y, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeMin() => new LIB_RedBlackTree<long, long, long>(long.MaxValue, 0, Math.Min, (x, y, c) => x + y, (x, y) => x + y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeMax() => new LIB_RedBlackTree<long, long, long>(long.MinValue, long.MaxValue - 100, Math.Max, (x, y, c) => y, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeMax() => new LIB_RedBlackTree<long, long, long>(long.MinValue, 0, Math.Max, (x, y, c) => x + y, (x, y) => x + y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeSum() => new LIB_RedBlackTree<long, long, long>(0, long.MaxValue, (x, y) => x + y, (x, y, c) => y * c, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeSum() => new LIB_RedBlackTree<long, long, long>(0, 0, (x, y) => x + y, (x, y, c) => x + y * c, (x, y) => x + y);
    }
    class LIB_RedBlackTree<Key, ValueT, ValueE> where ValueE : IEquatable<ValueE>
    {
        bool ope;
        class Node
        {
            public Node left;
            public Node right;
            public Key key;
            public ValueT val;
            public ValueT dat;
            public ValueE lazy;
            public bool isBlack;
            public int cnt;
            public bool needRecalc;
        }
        Func<ValueT, ValueT, ValueT> f;
        Func<ValueT, ValueE, int, ValueT> g;
        Func<ValueE, ValueE, ValueE> h;
        ValueT ti;
        ValueE ei;
        Comparison<Key> c;
        Node root;
        bool isNeedFix;
        Node lmax;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(ValueT ti, ValueE ei, Func<ValueT, ValueT, ValueT> f, Func<ValueT, ValueE, int, ValueT> g, Func<ValueE, ValueE, ValueE> h, Comparison<Key> c, bool ope = true)
        {
            this.ti = ti;
            this.ei = ei;
            this.f = f;
            this.g = g;
            this.h = h;
            this.c = c;
            this.ope = ope;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(ValueT ti, ValueE ei, Func<ValueT, ValueT, ValueT> f, Func<ValueT, ValueE, int, ValueT> g, Func<ValueE, ValueE, ValueE> h) : this(ti, ei, f, g, h, Comparer<Key>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        bool IsRed(Node n) => n != null && !n.isBlack;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        bool IsBlack(Node n) => n != null && n.isBlack;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        int Cnt(Node n) => n == null ? 0 : n.cnt;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Eval(Node n)
        {
            if (n == null || ei.Equals(n.lazy)) return;
            n.val = g(n.val, n.lazy, 1);
            if (!n.needRecalc) n.dat = g(n.dat, n.lazy, Cnt(n));
            if (n.left != null) n.left.lazy = h(n.left.lazy, n.lazy);
            if (n.right != null) n.right.lazy = h(n.right.lazy, n.lazy);
            n.lazy = ei;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Recalc(Node n)
        {
            if (n == null) return;
            Eval(n);
            if (!n.needRecalc) return;
            n.needRecalc = false;
            n.dat = n.val;
            if (n.left != null)
            {
                Recalc(n.left);
                n.dat = f(n.left.dat, n.dat);
            }
            if (n.right != null)
            {
                Recalc(n.right);
                n.dat = f(n.dat, n.right.dat);
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateL(Node n)
        {
            if (ope) { Eval(n); Eval(n.right); }
            Node m = n.right, t = m.left;
            m.left = n; n.right = t;
            n.cnt -= m.cnt - Cnt(t);
            m.cnt += n.cnt - Cnt(t);
            n.needRecalc = true; m.needRecalc = true;
            return m;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateR(Node n)
        {
            if (ope) { Eval(n); Eval(n.left); }
            Node m = n.left, t = m.right;
            m.right = n; n.left = t;
            n.cnt -= m.cnt - Cnt(t);
            m.cnt += n.cnt - Cnt(t);
            n.needRecalc = true; m.needRecalc = true;
            return m;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateLR(Node n)
        {
            n.left = RotateL(n.left);
            return RotateR(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateRL(Node n)
        {
            n.right = RotateR(n.right);
            return RotateL(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(Key key, ValueT val)
        {
            root = Add(root, key, val);
            root.isBlack = true;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Add(Node n, Key key, ValueT val)
        {
            if (n == null)
            {
                isNeedFix = true;
                return new Node() { key = key, val = val, dat = val, lazy = ei, cnt = 1 };
            }
            if (ope) Eval(n);
            if (c(key, n.key) < 0) n.left = Add(n.left, key, val);
            else n.right = Add(n.right, key, val);
            n.needRecalc = true;
            ++n.cnt;
            return Balance(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Balance(Node n)
        {
            if (!isNeedFix || !IsBlack(n)) return n;
            if (IsRed(n.left) && IsRed(n.left.left))
            {
                n = RotateR(n);
                n.left.isBlack = true;
            }
            else if (IsRed(n.left) && IsRed(n.left.right))
            {
                n = RotateLR(n);
                n.left.isBlack = true;
            }
            else if (IsRed(n.right) && IsRed(n.right.left))
            {
                n = RotateRL(n);
                n.right.isBlack = true;
            }
            else if (IsRed(n.right) && IsRed(n.right.right))
            {
                n = RotateL(n);
                n.right.isBlack = true;
            }
            else isNeedFix = false;
            return n;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(Key key)
        {
            root = Remove(root, key);
            if (root != null) root.isBlack = true;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Remove(Node n, Key key)
        {
            if (ope) Eval(n);
            --n.cnt;
            var r = c(key, n.key);
            if (r < 0)
            {
                n.left = Remove(n.left, key);
                n.needRecalc = true;
                return BalanceL(n);
            }
            if (r > 0)
            {
                n.right = Remove(n.right, key);
                n.needRecalc = true;
                return BalanceR(n);
            }
            if (n.left == null)
            {
                isNeedFix = n.isBlack;
                return n.right;
            }
            n.left = RemoveMax(n.left);
            n.key = lmax.key;
            n.val = lmax.val;
            n.needRecalc = true;
            return BalanceL(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RemoveMax(Node n)
        {
            if (ope) Eval(n);
            --n.cnt;
            if (n.right != null)
            {
                n.right = RemoveMax(n.right);
                n.needRecalc = true;
                return BalanceR(n);
            }
            lmax = n;
            isNeedFix = n.isBlack;
            return n.left;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node BalanceL(Node n)
        {
            if (!isNeedFix) return n;
            if (IsBlack(n.right) && IsRed(n.right.left))
            {
                var b = n.isBlack;
                n = RotateRL(n);
                n.isBlack = b;
                n.left.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.right) && IsRed(n.right.right))
            {
                var b = n.isBlack;
                n = RotateL(n);
                n.isBlack = b;
                n.right.isBlack = true;
                n.left.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.right))
            {
                isNeedFix = n.isBlack;
                n.isBlack = true;
                n.right.isBlack = false;
            }
            else
            {
                n = RotateL(n);
                n.isBlack = true;
                n.left.isBlack = false;
                n.left = BalanceL(n.left);
                isNeedFix = false;
            }
            return n;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node BalanceR(Node n)
        {
            if (!isNeedFix) return n;
            if (IsBlack(n.left) && IsRed(n.left.right))
            {
                var b = n.isBlack;
                n = RotateLR(n);
                n.isBlack = b; n.right.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.left) && IsRed(n.left.left))
            {
                var b = n.isBlack;
                n = RotateR(n);
                n.isBlack = b;
                n.left.isBlack = true;
                n.right.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.left))
            {
                isNeedFix = n.isBlack;
                n.isBlack = true;
                n.left.isBlack = false;
            }
            else
            {
                n = RotateR(n);
                n.isBlack = true;
                n.right.isBlack = false;
                n.right = BalanceR(n.right);
                isNeedFix = false;
            }
            return n;
        }
        public KeyValuePair<Key, ValueT> this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return At(root, i); }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        KeyValuePair<Key, ValueT> At(Node n, long i)
        {
            if (ope) Eval(n);
            if (n.left == null)
            {
                if (i == 0) return new KeyValuePair<Key, ValueT>(n.key, n.val);
                else return At(n.right, i - 1);
            }
            if (n.left.cnt == i) return new KeyValuePair<Key, ValueT>(n.key, n.val);
            if (n.left.cnt > i) return At(n.left, i);
            return At(n.right, i - n.left.cnt - 1);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(Key key)
        {
            var t = LowerBound(key);
            return t < Cnt(root) && c(At(root, t).Key, key) == 0;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(Key key) => UpperBound(root, key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        long UpperBound(Node n, Key key)
        {
            if (n == null) return 0;
            var r = c(key, n.key);
            if (r < 0) return UpperBound(n.left, key);
            return Cnt(n.left) + 1 + UpperBound(n.right, key);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(Key key) => LowerBound(root, key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        long LowerBound(Node n, Key key)
        {
            if (n == null) return 0;
            var r = c(key, n.key);
            if (r <= 0) return LowerBound(n.left, key);
            return Cnt(n.left) + 1 + LowerBound(n.right, key);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, ValueT> Min()
        {
            Node n = root.left, p = root;
            while (n != null)
            {
                p = n;
                if (ope) Eval(p);
                n = n.left;
            }
            return new KeyValuePair<Key, ValueT>(p.key, p.val);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, ValueT> Max()
        {
            Node n = root.right, p = root;
            while (n != null)
            {
                p = n;
                if (ope) Eval(p);
                n = n.right;
            }
            return new KeyValuePair<Key, ValueT>(p.key, p.val);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Update(long l, long r, ValueE val) => Update(root, l, r, val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Update(Node n, long l, long r, ValueE val)
        {
            if (n == null) return;
            Eval(n);
            n.needRecalc = true;
            var lc = Cnt(n.left);
            if (lc < l) Update(n.right, l - lc - 1, r - lc - 1, val);
            else if (r <= lc) Update(n.left, l, r, val);
            else if (l <= 0 && Cnt(n) <= r) n.lazy = val;
            else
            {
                n.val = g(n.val, val, 1);
                if (l < lc) Update(n.left, l, lc, val);
                if (lc + 1 < r) Update(n.right, 0, r - lc - 1, val);
            }
            return;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public ValueT Query(long l, long r) => Query(root, l, r);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        ValueT Query(Node n, long l, long r)
        {
            var v1 = ti; var v2 = ti; var v3 = ti;
            if (n == null) return ti;
            Eval(n);
            var lc = Cnt(n.left);
            if (lc < l) v3 = Query(n.right, l - lc - 1, r - lc - 1);
            else if (r <= lc) v1 = Query(n.left, l, r);
            else if (l <= 0 && Cnt(n) <= r)
            {
                Recalc(n);
                v2 = n.dat;
            }
            else
            {
                if (l < lc) v1 = Query(n.left, l, lc);
                if (lc + 1 < r) v3 = Query(n.right, 0, r - lc - 1);
                v2 = n.val;
            }
            return f(f(v1, v2), v3);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => root != null;
        public long Count => Cnt(root);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<KeyValuePair<Key, ValueT>> List() => L(root);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        IEnumerable<KeyValuePair<Key, ValueT>> L(Node n)
        {
            if (n == null) yield break;
            foreach (var i in L(n.left)) yield return i;
            yield return new KeyValuePair<Key, ValueT>(n.key, n.val);
            foreach (var i in L(n.right)) yield return i;
        }
    }
    class LIB_RedBlackTree<Key, Value>
    {
        LIB_RedBlackTree<Key, Value, int> tree;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(Comparison<Key> c) { tree = new LIB_RedBlackTree<Key, Value, int>(default(Value), 0, null, null, null, c, false); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree() : this(Comparer<Key>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(Key key, Value val) => tree.Add(key, val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(Key key) => tree.Remove(key);
        public KeyValuePair<Key, Value> this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return tree[i]; }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(Key key) => tree.ContainsKey(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(Key key) => tree.UpperBound(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(Key key) => tree.LowerBound(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, Value> Min() => tree.Min();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, Value> Max() => tree.Max();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => tree.Any();
        public long Count => tree.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<KeyValuePair<Key, Value>> List() => tree.List();
    }
    class LIB_RedBlackTree<T>
    {
        LIB_RedBlackTree<T, int, int> tree;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(Comparison<T> c) { tree = new LIB_RedBlackTree<T, int, int>(0, 0, null, null, null, c, false); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree() : this(Comparer<T>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(T val) => tree.Add(val, 0);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(T val) => tree.Remove(val);
        public T this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return tree[i].Key; }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(T val) => tree.ContainsKey(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(T val) => tree.UpperBound(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(T val) => tree.LowerBound(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Min() => tree.Min().Key;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Max() => tree.Max().Key;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => tree.Any();
        public long Count => tree.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<T> List() => tree.List().Select(e => e.Key);
    }
    class LIB_UnionFind<T>
    {
        int[] d;
        Stack<(int, int)> h;
        Stack<T> hv;
        T[] v;
        Func<T, T, T> f;
        Func<T, T, (T, T)> rf;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(IEnumerable<T> s, Func<T, T, T> func, Func<T, T, (T, T)> revFunc)
        {
            v = s.ToArray();
            d = Enumerable.Repeat(-1, v.Length).ToArray();
            f = func;
            rf = revFunc;
            h = new Stack<(int, int)>();
            hv = new Stack<T>();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Unite(long x, long y)
        {
            x = Root(x);
            y = Root(y);
            h.Push(((int)y, d[y]));
            h.Push(((int)x, d[x]));
            if (x != y)
            {
                hv.Push(v[y]);
                hv.Push(v[x]);
                d[x] = d[x] + d[y];
                v[x] = f(v[x], v[y]);
                d[y] = (int)x;
            }
            return x != y;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Undo()
        {
            var pop1 = h.Pop();
            var pop2 = h.Pop();
            if (pop1.Item1 == pop2.Item1) return;
            d[pop1.Item1] = pop1.Item2;
            d[pop2.Item1] = pop2.Item2;
            var popv1 = hv.Pop();
            var popv2 = hv.Pop();
            var undoValue = rf(popv1, popv2);
            v[pop1.Item1] = undoValue.Item1;
            v[pop2.Item1] = undoValue.Item2;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool IsSame(long x, long y) => Root(x) == Root(y);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Root(long x) => d[x] < 0 ? x : d[x] = (int)Root(d[x]);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Count(long x) => -d[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Calc(long x) => v[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Snapshot() => h.Clear();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Rollback()
        {
            while (h.Count > 0) Undo();
        }
    }
    class LIB_UnionFind : LIB_UnionFind<int>
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(long n) : base(Enumerable.Repeat(0, (int)n), (x, y) => x + y, (x, y) =>
        {
            if (x < y) return (x, y - x);
            else return (x - y, y);
        })
        { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        new private void Calc(long x) { }
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ProblemD
    {
        static bool SAIKI = false;
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var n = NN;
            var m = NN;
            var q = NN;
            var pList = NNList(n);
            var ab = Repeat(0, m).Select(_ => new { a = NN - 1, b = NN - 1 }).ToArray();
            var query = Repeat(0, q).Select(_ => new { t = NN, param = NN }).ToArray();
            var deleteTgt = new bool[m];
            var uf = new LIB_UnionFind<LIB_PriorityQueue>(pList.Select((e, idx) =>
            {
                var ret = new LIB_PriorityQueue();
                ret.Push(e, idx);
                return ret;
            }), (x, y) =>
            {
                if (x.Count > y.Count)
                {
                    for (var i = 0; i < y.Count; i++)
                    {
                        x.Push(y.heap[i], y.dat[i]);
                    }
                    return x;
                }
                else
                {
                    for (var i = 0; i < x.Count; i++)
                    {
                        y.Push(x.heap[i], x.dat[i]);
                    }
                    return y;
                }
            });
            foreach (var item in query)
            {
                if (item.t == 2) deleteTgt[item.param - 1] = true;
            }
            for (var i = 0; i < m; i++)
            {
                if (!deleteTgt[i])
                {
                    uf.Unite(ab[i].a, ab[i].b);
                }
            }
            var ans = new List<LIB_PriorityQueue>();
            for (var qqq = q - 1; qqq >= 0; qqq--)
            {
                if (query[qqq].t == 1)
                {
                    var v = query[qqq].param - 1;
                    ans.Add(uf.Calc(v));
                }
                else
                {
                    var i = query[qqq].param - 1;
                    uf.Unite(ab[i].a, ab[i].b);
                }
            }
            ans.Reverse();
            var deleted = new bool[n + 1];
            foreach (var item in ans)
            {
                var ok = false;
                while (item.Count > 0)
                {
                    var value = item.Pop();
                    if (!deleted[value.Key])
                    {
                        deleted[value.Key] = true;
                        Console.WriteLine(value.Key);
                        ok = true;
                        break;
                    }
                }
                if (!ok) Console.WriteLine(0);
            }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static LIB_FastIO fastio = new LIB_FastIODebug();
        static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }
        static long NN => fastio.Long();
        static double ND => fastio.Double();
        static string NS => fastio.Scan();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);
        static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);
        static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
        static bool Chmax<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }
        static bool Chmin<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }
    }
}
namespace Library {
    class LIB_UnionFind<T>
    {
        int[] d;
        T[] v;
        Func<T, T, T> f;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(IEnumerable<T> s, Func<T, T, T> func)
        {
            v = s.ToArray();
            d = Enumerable.Repeat(-1, v.Length).ToArray();
            f = func;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Unite(long x, long y)
        {
            x = Root(x);
            y = Root(y);
            if (x != y)
            {
                d[x] = d[x] + d[y];
                v[x] = f(v[x], v[y]);
                d[y] = (int)x;
            }
            return x != y;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool IsSame(long x, long y) => Root(x) == Root(y);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Root(long x) => d[x] < 0 ? x : d[x] = (int)Root(d[x]);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Count(long x) => -d[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Calc(long x) => v[Root(x)];
    }
    class LIB_UnionFind : LIB_UnionFind<int>
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(long n) : base(Enumerable.Repeat(0, (int)n), (x, y) => x + y) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        new private void Calc(long x) { }
    }
    class LIB_FastIO
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIO() { str = Console.OpenStandardInput(); }
        readonly Stream str;
        readonly byte[] buf = new byte[2048];
        int len, ptr;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        byte read()
        {
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 2048)) <= 0)
                {
                    return 0;
                }
            }
            return buf[ptr++];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = (ret << 3) + (ret << 1) + b - '0';
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
    class LIB_FastIODebug : LIB_FastIO
    {
        Queue<string> param = new Queue<string>();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIODebug() { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string Scan() => NextString();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override long Long() => long.Parse(NextString());
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override double Double() => double.Parse(NextString());
    }
    class LIB_PriorityQueue
    {
        public long[] heap;
        public int[] dat;
        public long Count
        {
            get;
            private set;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue()
        {
            heap = new long[163];
            dat = new int[163];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(long key, int val)
        {
            if (Count == heap.Length) Expand();
            var i = Count++;
            heap[i] = key;
            dat[i] = val;
            while (i > 0)
            {
                var ni = (i - 1) / 2;
                if (key <= heap[ni]) break;
                heap[i] = heap[ni];
                dat[i] = dat[ni];
                i = ni;
            }
            heap[i] = key;
            dat[i] = val;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<long, int> Pop()
        {
            var ret = new KeyValuePair<long, int>(heap[0], dat[0]);
            var key = heap[--Count];
            var val = dat[Count];
            if (Count == 0) return ret;
            var i = 0; while ((i << 1) + 1 < Count)
            {
                var i1 = (i << 1) + 1;
                var i2 = (i << 1) + 2;
                if (i2 < Count && heap[i1] < heap[i2]) i1 = i2;
                if (key >= heap[i1]) break;
                heap[i] = heap[i1];
                dat[i] = dat[i1];
                i = i1;
            }
            heap[i] = key;
            dat[i] = val;
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Expand()
        {
            var tmp = new long[Count << 1];
            for (var i = 0; i < heap.Length; ++i) tmp[i] = heap[i];
            heap = tmp;
            var tmp2 = new int[Count << 1];
            for (var i = 0; i < dat.Length; ++i) tmp2[i] = dat[i];
            dat = tmp2;
        }
    }
    class LIB_PriorityQueue<T>
    {
        T[] heap;
        Comparison<T> comp;
        public T Peek => heap[0];
        public long Count
        {
            get;
            private set;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, Comparison<T> cmp, bool asc = true)
        {
            heap = new T[cap];
            comp = asc ? cmp : (x, y) => cmp(y, x);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(Comparison<T> cmp, bool asc = true)
        {
            heap = new T[16384];
            comp = asc ? cmp : (x, y) => cmp(y, x);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, bool asc = true) : this(cap, Comparer<T>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(bool asc = true) : this(Comparer<T>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(T val)
        {
            if (Count == heap.Length) Expand();
            var i = Count++;
            heap[i] = val;
            while (i > 0)
            {
                var ni = (i - 1) / 2;
                if (comp(val, heap[ni]) >= 0) break;
                heap[i] = heap[ni];
                i = ni;
            }
            heap[i] = val;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Pop()
        {
            var ret = heap[0];
            var val = heap[--Count];
            if (Count == 0) return ret;
            var i = 0; while ((i << 1) + 1 < Count)
            {
                var i1 = (i << 1) + 1;
                var i2 = (i << 1) + 2;
                if (i2 < Count && comp(heap[i1], heap[i2]) > 0) i1 = i2;
                if (comp(val, heap[i1]) <= 0) break;
                heap[i] = heap[i1]; i = i1;
            }
            heap[i] = val;
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Expand()
        {
            var tmp = new T[Count << 1];
            for (var i = 0; i < heap.Length; ++i) tmp[i] = heap[i];
            heap = tmp;
        }
    }
    class LIB_PriorityQueue<TK, TV>
    {
        LIB_PriorityQueue<KeyValuePair<TK, TV>> q;
        public KeyValuePair<TK, TV> Peek => q.Peek;
        public long Count => q.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, Comparison<TK> cmp, bool asc = true)
        {
            q = new LIB_PriorityQueue<KeyValuePair<TK, TV>>(cap, (x, y) => cmp(x.Key, y.Key), asc);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(Comparison<TK> cmp, bool asc = true)
        {
            q = new LIB_PriorityQueue<KeyValuePair<TK, TV>>((x, y) => cmp(x.Key, y.Key), asc);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, bool asc = true) : this(cap, Comparer<TK>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(bool asc = true) : this(Comparer<TK>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(TK k, TV v) => q.Push(new KeyValuePair<TK, TV>(k, v));
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<TK, TV> Pop() => q.Pop();
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ProblemD
    {
        static bool SAIKI = false;
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var n = (int)NN;
            var m = (int)NN;
            var q = (int)NN;
            var pList = NNList(n);
            var ab = Repeat(0, m).Select(_ => new { a = (int)NN - 1, b = (int)NN - 1 }).ToArray();
            var query = Repeat(0, q).Select(_ => new { t = (int)NN, param = (int)NN }).ToArray();
            var uf = new LIB_UnionFind<LIB_RedBlackTree<long>>(Range(0, n).Select(e =>
            {
                var ret = new LIB_RedBlackTree<long>();
                ret.Add(pList[e]);
                return ret;
            }), (x, y) =>
            {
                var rt = LIB_UnionFind.RootVtx.X;
                if (x.Count > y.Count) { var t = x; x = y; y = t; rt = LIB_UnionFind.RootVtx.Y; }
                foreach (var item in y.List()) x.Add(item);
                return (rt, x);
            }, (x, y) =>
            {
                foreach (var item in y.List().ToArray())
                {
                    if (x.ContainsKey(item)) x.Remove(item);
                    else y.Remove(item);
                }
                return (x, y);
            });
            var deleted = new bool[m];
            foreach (var item in query)
            {
                if (item.t == 2) deleted[item.param - 1] = true;
            }
            for (var i = 0; i < m; i++)
            {
                if (!deleted[i]) uf.Unite(ab[i].a, ab[i].b);
            }
            foreach (var item in query.Reverse())
            {
                if (item.t == 2) uf.Unite(ab[item.param - 1].a, ab[item.param - 1].b);
            }
            foreach (var item in query)
            {
                if (item.t == 1)
                {
                    var set = uf.Calc(item.param - 1);
                    var value = 0L;
                    if (set.Count > 0)
                    {
                        value = set.Max();
                        set.Remove(value);
                    }
                    Console.WriteLine(value);
                }
                else uf.Undo();
            }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static LIB_FastIO fastio = new LIB_FastIODebug();
        static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }
        static long NN => fastio.Long();
        static double ND => fastio.Double();
        static string NS => fastio.Scan();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);
        static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);
        static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
        static bool Chmax<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }
        static bool Chmin<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }
    }
}
namespace Library {
    class LIB_RedBlackTree
    {
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeMin() => new LIB_RedBlackTree<long, long, long>(long.MaxValue, long.MinValue + 100, Math.Min, (x, y, c) => y, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeMin() => new LIB_RedBlackTree<long, long, long>(long.MaxValue, 0, Math.Min, (x, y, c) => x + y, (x, y) => x + y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeMax() => new LIB_RedBlackTree<long, long, long>(long.MinValue, long.MaxValue - 100, Math.Max, (x, y, c) => y, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeMax() => new LIB_RedBlackTree<long, long, long>(long.MinValue, 0, Math.Max, (x, y, c) => x + y, (x, y) => x + y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeSum() => new LIB_RedBlackTree<long, long, long>(0, long.MaxValue, (x, y) => x + y, (x, y, c) => y * c, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeSum() => new LIB_RedBlackTree<long, long, long>(0, 0, (x, y) => x + y, (x, y, c) => x + y * c, (x, y) => x + y);
    }
    class LIB_RedBlackTree<Key, ValueT, ValueE> where ValueE : IEquatable<ValueE>
    {
        bool ope;
        class Node
        {
            public Node left;
            public Node right;
            public Key key;
            public ValueT val;
            public ValueT dat;
            public ValueE lazy;
            public bool isBlack;
            public int cnt;
            public bool needRecalc;
        }
        Func<ValueT, ValueT, ValueT> f;
        Func<ValueT, ValueE, int, ValueT> g;
        Func<ValueE, ValueE, ValueE> h;
        ValueT ti;
        ValueE ei;
        Comparison<Key> c;
        Node root;
        bool isNeedFix;
        Node lmax;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(ValueT ti, ValueE ei, Func<ValueT, ValueT, ValueT> f, Func<ValueT, ValueE, int, ValueT> g, Func<ValueE, ValueE, ValueE> h, Comparison<Key> c, bool ope = true)
        {
            this.ti = ti;
            this.ei = ei;
            this.f = f;
            this.g = g;
            this.h = h;
            this.c = c;
            this.ope = ope;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(ValueT ti, ValueE ei, Func<ValueT, ValueT, ValueT> f, Func<ValueT, ValueE, int, ValueT> g, Func<ValueE, ValueE, ValueE> h) : this(ti, ei, f, g, h, Comparer<Key>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        bool IsRed(Node n) => n != null && !n.isBlack;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        bool IsBlack(Node n) => n != null && n.isBlack;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        int Cnt(Node n) => n == null ? 0 : n.cnt;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Eval(Node n)
        {
            if (n == null || ei.Equals(n.lazy)) return;
            n.val = g(n.val, n.lazy, 1);
            if (!n.needRecalc) n.dat = g(n.dat, n.lazy, Cnt(n));
            if (n.left != null) n.left.lazy = h(n.left.lazy, n.lazy);
            if (n.right != null) n.right.lazy = h(n.right.lazy, n.lazy);
            n.lazy = ei;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Recalc(Node n)
        {
            if (n == null) return;
            Eval(n);
            if (!n.needRecalc) return;
            n.needRecalc = false;
            n.dat = n.val;
            if (n.left != null)
            {
                Recalc(n.left);
                n.dat = f(n.left.dat, n.dat);
            }
            if (n.right != null)
            {
                Recalc(n.right);
                n.dat = f(n.dat, n.right.dat);
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateL(Node n)
        {
            if (ope) { Eval(n); Eval(n.right); }
            Node m = n.right, t = m.left;
            m.left = n; n.right = t;
            n.cnt -= m.cnt - Cnt(t);
            m.cnt += n.cnt - Cnt(t);
            n.needRecalc = true; m.needRecalc = true;
            return m;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateR(Node n)
        {
            if (ope) { Eval(n); Eval(n.left); }
            Node m = n.left, t = m.right;
            m.right = n; n.left = t;
            n.cnt -= m.cnt - Cnt(t);
            m.cnt += n.cnt - Cnt(t);
            n.needRecalc = true; m.needRecalc = true;
            return m;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateLR(Node n)
        {
            n.left = RotateL(n.left);
            return RotateR(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateRL(Node n)
        {
            n.right = RotateR(n.right);
            return RotateL(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(Key key, ValueT val)
        {
            root = Add(root, key, val);
            root.isBlack = true;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Add(Node n, Key key, ValueT val)
        {
            if (n == null)
            {
                isNeedFix = true;
                return new Node() { key = key, val = val, dat = val, lazy = ei, cnt = 1 };
            }
            if (ope) Eval(n);
            if (c(key, n.key) < 0) n.left = Add(n.left, key, val);
            else n.right = Add(n.right, key, val);
            n.needRecalc = true;
            ++n.cnt;
            return Balance(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Balance(Node n)
        {
            if (!isNeedFix || !IsBlack(n)) return n;
            if (IsRed(n.left) && IsRed(n.left.left))
            {
                n = RotateR(n);
                n.left.isBlack = true;
            }
            else if (IsRed(n.left) && IsRed(n.left.right))
            {
                n = RotateLR(n);
                n.left.isBlack = true;
            }
            else if (IsRed(n.right) && IsRed(n.right.left))
            {
                n = RotateRL(n);
                n.right.isBlack = true;
            }
            else if (IsRed(n.right) && IsRed(n.right.right))
            {
                n = RotateL(n);
                n.right.isBlack = true;
            }
            else isNeedFix = false;
            return n;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(Key key)
        {
            root = Remove(root, key);
            if (root != null) root.isBlack = true;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Remove(Node n, Key key)
        {
            if (ope) Eval(n);
            --n.cnt;
            var r = c(key, n.key);
            if (r < 0)
            {
                n.left = Remove(n.left, key);
                n.needRecalc = true;
                return BalanceL(n);
            }
            if (r > 0)
            {
                n.right = Remove(n.right, key);
                n.needRecalc = true;
                return BalanceR(n);
            }
            if (n.left == null)
            {
                isNeedFix = n.isBlack;
                return n.right;
            }
            n.left = RemoveMax(n.left);
            n.key = lmax.key;
            n.val = lmax.val;
            n.needRecalc = true;
            return BalanceL(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RemoveMax(Node n)
        {
            if (ope) Eval(n);
            --n.cnt;
            if (n.right != null)
            {
                n.right = RemoveMax(n.right);
                n.needRecalc = true;
                return BalanceR(n);
            }
            lmax = n;
            isNeedFix = n.isBlack;
            return n.left;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node BalanceL(Node n)
        {
            if (!isNeedFix) return n;
            if (IsBlack(n.right) && IsRed(n.right.left))
            {
                var b = n.isBlack;
                n = RotateRL(n);
                n.isBlack = b;
                n.left.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.right) && IsRed(n.right.right))
            {
                var b = n.isBlack;
                n = RotateL(n);
                n.isBlack = b;
                n.right.isBlack = true;
                n.left.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.right))
            {
                isNeedFix = n.isBlack;
                n.isBlack = true;
                n.right.isBlack = false;
            }
            else
            {
                n = RotateL(n);
                n.isBlack = true;
                n.left.isBlack = false;
                n.left = BalanceL(n.left);
                isNeedFix = false;
            }
            return n;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node BalanceR(Node n)
        {
            if (!isNeedFix) return n;
            if (IsBlack(n.left) && IsRed(n.left.right))
            {
                var b = n.isBlack;
                n = RotateLR(n);
                n.isBlack = b; n.right.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.left) && IsRed(n.left.left))
            {
                var b = n.isBlack;
                n = RotateR(n);
                n.isBlack = b;
                n.left.isBlack = true;
                n.right.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.left))
            {
                isNeedFix = n.isBlack;
                n.isBlack = true;
                n.left.isBlack = false;
            }
            else
            {
                n = RotateR(n);
                n.isBlack = true;
                n.right.isBlack = false;
                n.right = BalanceR(n.right);
                isNeedFix = false;
            }
            return n;
        }
        public KeyValuePair<Key, ValueT> this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return At(root, i); }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        KeyValuePair<Key, ValueT> At(Node n, long i)
        {
            if (ope) Eval(n);
            if (n.left == null)
            {
                if (i == 0) return new KeyValuePair<Key, ValueT>(n.key, n.val);
                else return At(n.right, i - 1);
            }
            if (n.left.cnt == i) return new KeyValuePair<Key, ValueT>(n.key, n.val);
            if (n.left.cnt > i) return At(n.left, i);
            return At(n.right, i - n.left.cnt - 1);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(Key key)
        {
            var t = LowerBound(key);
            return t < Cnt(root) && c(At(root, t).Key, key) == 0;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(Key key) => UpperBound(root, key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        long UpperBound(Node n, Key key)
        {
            if (n == null) return 0;
            var r = c(key, n.key);
            if (r < 0) return UpperBound(n.left, key);
            return Cnt(n.left) + 1 + UpperBound(n.right, key);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(Key key) => LowerBound(root, key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        long LowerBound(Node n, Key key)
        {
            if (n == null) return 0;
            var r = c(key, n.key);
            if (r <= 0) return LowerBound(n.left, key);
            return Cnt(n.left) + 1 + LowerBound(n.right, key);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, ValueT> Min()
        {
            Node n = root.left, p = root;
            while (n != null)
            {
                p = n;
                if (ope) Eval(p);
                n = n.left;
            }
            return new KeyValuePair<Key, ValueT>(p.key, p.val);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, ValueT> Max()
        {
            Node n = root.right, p = root;
            while (n != null)
            {
                p = n;
                if (ope) Eval(p);
                n = n.right;
            }
            return new KeyValuePair<Key, ValueT>(p.key, p.val);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Update(long l, long r, ValueE val) => Update(root, l, r, val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Update(Node n, long l, long r, ValueE val)
        {
            if (n == null) return;
            Eval(n);
            n.needRecalc = true;
            var lc = Cnt(n.left);
            if (lc < l) Update(n.right, l - lc - 1, r - lc - 1, val);
            else if (r <= lc) Update(n.left, l, r, val);
            else if (l <= 0 && Cnt(n) <= r) n.lazy = val;
            else
            {
                n.val = g(n.val, val, 1);
                if (l < lc) Update(n.left, l, lc, val);
                if (lc + 1 < r) Update(n.right, 0, r - lc - 1, val);
            }
            return;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public ValueT Query(long l, long r) => Query(root, l, r);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        ValueT Query(Node n, long l, long r)
        {
            var v1 = ti; var v2 = ti; var v3 = ti;
            if (n == null) return ti;
            Eval(n);
            var lc = Cnt(n.left);
            if (lc < l) v3 = Query(n.right, l - lc - 1, r - lc - 1);
            else if (r <= lc) v1 = Query(n.left, l, r);
            else if (l <= 0 && Cnt(n) <= r)
            {
                Recalc(n);
                v2 = n.dat;
            }
            else
            {
                if (l < lc) v1 = Query(n.left, l, lc);
                if (lc + 1 < r) v3 = Query(n.right, 0, r - lc - 1);
                v2 = n.val;
            }
            return f(f(v1, v2), v3);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => root != null;
        public long Count => Cnt(root);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<KeyValuePair<Key, ValueT>> List() => L(root);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        IEnumerable<KeyValuePair<Key, ValueT>> L(Node n)
        {
            if (n == null) yield break;
            foreach (var i in L(n.left)) yield return i;
            yield return new KeyValuePair<Key, ValueT>(n.key, n.val);
            foreach (var i in L(n.right)) yield return i;
        }
    }
    class LIB_RedBlackTree<Key, Value>
    {
        LIB_RedBlackTree<Key, Value, int> tree;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(Comparison<Key> c) { tree = new LIB_RedBlackTree<Key, Value, int>(default(Value), 0, null, null, null, c, false); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree() : this(Comparer<Key>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(Key key, Value val) => tree.Add(key, val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(Key key) => tree.Remove(key);
        public KeyValuePair<Key, Value> this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return tree[i]; }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(Key key) => tree.ContainsKey(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(Key key) => tree.UpperBound(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(Key key) => tree.LowerBound(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, Value> Min() => tree.Min();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, Value> Max() => tree.Max();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => tree.Any();
        public long Count => tree.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<KeyValuePair<Key, Value>> List() => tree.List();
    }
    class LIB_RedBlackTree<T>
    {
        LIB_RedBlackTree<T, int, int> tree;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(Comparison<T> c) { tree = new LIB_RedBlackTree<T, int, int>(0, 0, null, null, null, c, false); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree() : this(Comparer<T>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(T val) => tree.Add(val, 0);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(T val) => tree.Remove(val);
        public T this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return tree[i].Key; }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(T val) => tree.ContainsKey(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(T val) => tree.UpperBound(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(T val) => tree.LowerBound(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Min() => tree.Min().Key;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Max() => tree.Max().Key;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => tree.Any();
        public long Count => tree.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<T> List() => tree.List().Select(e => e.Key);
    }
    class LIB_UnionFind<T>
    {
        int[] d;
        Stack<(int, int)> h;
        T[] v;
        Func<T, T, (LIB_UnionFind.RootVtx, T)> f;
        Func<T, T, (T, T)> rf;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(IEnumerable<T> s, Func<T, T, (LIB_UnionFind.RootVtx, T)> func, Func<T, T, (T, T)> revFunc)
        {
            v = s.ToArray();
            d = Enumerable.Repeat(-1, v.Length).ToArray();
            f = func;
            rf = revFunc;
            h = new Stack<(int, int)>();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Unite(long x, long y)
        {
            x = Root(x);
            y = Root(y);
            if (x != y)
            {
                var (root, value) = f(v[x], v[y]);
                if (root == LIB_UnionFind.RootVtx.X)
                {
                    h.Push(((int)y, d[y]));
                    h.Push(((int)x, d[x]));
                    d[x] = d[x] + d[y];
                    d[y] = (int)x;
                    v[x] = value;
                }
                else
                {
                    h.Push(((int)x, d[x]));
                    h.Push(((int)y, d[y]));
                    d[y] = d[x] + d[y];
                    d[x] = (int)y;
                    v[y] = value;
                }
            }
            else
            {
                h.Push(((int)y, d[y]));
                h.Push(((int)x, d[x]));
            }
            return x != y;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Undo()
        {
            var pop1 = h.Pop();
            var pop2 = h.Pop();
            if (pop1.Item1 == pop2.Item1) return;
            d[pop1.Item1] = pop1.Item2;
            d[pop2.Item1] = pop2.Item2;
            (v[pop1.Item1], v[pop2.Item1]) = rf(v[pop1.Item1], v[pop2.Item1]);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool IsSame(long x, long y) => Root(x) == Root(y);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Root(long x) => d[x] < 0 ? x : d[x] = (int)Root(d[x]);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Count(long x) => -d[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Calc(long x) => v[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Snapshot() => h.Clear();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Rollback()
        {
            while (h.Count > 0) Undo();
        }
    }
    class LIB_UnionFind : LIB_UnionFind<int>
    {
        public enum RootVtx { X, Y };
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(long n) : base(Enumerable.Repeat(0, (int)n), (x, y) => (RootVtx.X, x + y), (x, y) =>
        {
            if (x < y) return (x, y - x);
            else return (x - y, y);
        })
        { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        new private void Calc(long x) { }
    }
    class LIB_FastIO
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIO() { str = Console.OpenStandardInput(); }
        readonly Stream str;
        readonly byte[] buf = new byte[2048];
        int len, ptr;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        byte read()
        {
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 2048)) <= 0)
                {
                    return 0;
                }
            }
            return buf[ptr++];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = (ret << 3) + (ret << 1) + b - '0';
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
    class LIB_FastIODebug : LIB_FastIO
    {
        Queue<string> param = new Queue<string>();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIODebug() { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string Scan() => NextString();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override long Long() => long.Parse(NextString());
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override double Double() => double.Parse(NextString());
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ProblemD
    {
        static bool SAIKI = false;
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var n = (int)NN;
            var m = (int)NN;
            var q = (int)NN;
            var pList = NNList(n);
            var ab = Repeat(0, m).Select(_ => new { a = (int)NN - 1, b = (int)NN - 1 }).ToArray();
            var query = Repeat(0, q).Select(_ => new { t = (int)NN, param = (int)NN }).ToArray();
            var uf = new LIB_UnionFind<LIB_RedBlackTree<long>>(Range(0, n).Select(e =>
            {
                var ret = new LIB_RedBlackTree<long>();
                ret.Add(pList[e]);
                return ret;
            }), (x, y) =>
            {
                if (x.Count > y.Count) { var t = x; x = y; y = t; }
                foreach (var item in x.List()) y.Add(item);
                return y;
            }, (x, y) =>
            {
                var rev = false;
                if (x.Count > y.Count)
                {
                    var t = x; x = y; y = t;
                    rev = true;
                }
                foreach (var item in x.List().ToArray())
                {
                    if (y.ContainsKey(item)) y.Remove(item);
                    else x.Remove(item);
                }
                if (rev) return (y, x);
                else return (x, y);
            });
            var deleted = new bool[m];
            foreach (var item in query)
            {
                if (item.t == 2) deleted[item.param - 1] = true;
            }
            for (var i = 0; i < m; i++)
            {
                if (!deleted[i]) uf.Unite(ab[i].a, ab[i].b);
            }
            foreach (var item in query.Reverse())
            {
                if (item.t == 2) uf.Unite(ab[item.param - 1].a, ab[item.param - 1].b);
            }
            foreach (var item in query)
            {
                if (item.t == 1)
                {
                    var set = uf.Calc(item.param - 1);
                    var value = 0L;
                    if (set.Count > 0)
                    {
                        value = set.Max();
                        set.Remove(value);
                    }
                    Console.WriteLine(value);
                }
                else uf.Undo();
            }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static LIB_FastIO fastio = new LIB_FastIODebug();
        static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }
        static long NN => fastio.Long();
        static double ND => fastio.Double();
        static string NS => fastio.Scan();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);
        static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);
        static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
        static bool Chmax<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }
        static bool Chmin<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }
    }
}
namespace Library {
    class LIB_UnionFind<T>
    {
        int[] d;
        Stack<(int, int)> h;
        Stack<T> hv;
        T[] v;
        Func<T, T, T> f;
        Func<T, T, (T, T)> rf;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(IEnumerable<T> s, Func<T, T, T> func, Func<T, T, (T, T)> revFunc)
        {
            v = s.ToArray();
            d = Enumerable.Repeat(-1, v.Length).ToArray();
            f = func;
            rf = revFunc;
            h = new Stack<(int, int)>();
            hv = new Stack<T>();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Unite(long x, long y)
        {
            x = Root(x);
            y = Root(y);
            h.Push(((int)x, d[x]));
            h.Push(((int)y, d[y]));
            if (x != y)
            {
                hv.Push(v[x]);
                hv.Push(v[y]);
                d[x] = d[x] + d[y];
                v[x] = f(v[x], v[y]);
                d[y] = (int)x;
            }
            return x != y;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Undo()
        {
            var pop1 = h.Pop();
            var pop2 = h.Pop();
            if (pop1.Item1 == pop2.Item1) return;
            d[pop1.Item1] = pop1.Item2;
            d[pop2.Item1] = pop2.Item2;
            var popv1 = hv.Pop();
            var popv2 = hv.Pop();
            var undoValue = rf(popv1, popv2);
            v[pop1.Item1] = undoValue.Item1;
            v[pop2.Item1] = undoValue.Item2;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool IsSame(long x, long y) => Root(x) == Root(y);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Root(long x) => d[x] < 0 ? x : d[x] = (int)Root(d[x]);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Count(long x) => -d[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Calc(long x) => v[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Snapshot() => h.Clear();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Rollback()
        {
            while (h.Count > 0) Undo();
        }
    }
    class LIB_UnionFind : LIB_UnionFind<int>
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(long n) : base(Enumerable.Repeat(0, (int)n), (x, y) => x + y, (x, y) =>
        {
            if (x < y) return (x, y - x);
            else return (x - y, y);
        })
        { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        new private void Calc(long x) { }
    }
    class LIB_FastIO
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIO() { str = Console.OpenStandardInput(); }
        readonly Stream str;
        readonly byte[] buf = new byte[2048];
        int len, ptr;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        byte read()
        {
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 2048)) <= 0)
                {
                    return 0;
                }
            }
            return buf[ptr++];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = (ret << 3) + (ret << 1) + b - '0';
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
    class LIB_FastIODebug : LIB_FastIO
    {
        Queue<string> param = new Queue<string>();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIODebug() { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string Scan() => NextString();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override long Long() => long.Parse(NextString());
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override double Double() => double.Parse(NextString());
    }
    class LIB_RedBlackTree
    {
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeMin() => new LIB_RedBlackTree<long, long, long>(long.MaxValue, long.MinValue + 100, Math.Min, (x, y, c) => y, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeMin() => new LIB_RedBlackTree<long, long, long>(long.MaxValue, 0, Math.Min, (x, y, c) => x + y, (x, y) => x + y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeMax() => new LIB_RedBlackTree<long, long, long>(long.MinValue, long.MaxValue - 100, Math.Max, (x, y, c) => y, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeMax() => new LIB_RedBlackTree<long, long, long>(long.MinValue, 0, Math.Max, (x, y, c) => x + y, (x, y) => x + y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeSum() => new LIB_RedBlackTree<long, long, long>(0, long.MaxValue, (x, y) => x + y, (x, y, c) => y * c, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeSum() => new LIB_RedBlackTree<long, long, long>(0, 0, (x, y) => x + y, (x, y, c) => x + y * c, (x, y) => x + y);
    }
    class LIB_RedBlackTree<Key, ValueT, ValueE> where ValueE : IEquatable<ValueE>
    {
        bool ope;
        class Node
        {
            public Node left;
            public Node right;
            public Key key;
            public ValueT val;
            public ValueT dat;
            public ValueE lazy;
            public bool isBlack;
            public int cnt;
            public bool needRecalc;
        }
        Func<ValueT, ValueT, ValueT> f;
        Func<ValueT, ValueE, int, ValueT> g;
        Func<ValueE, ValueE, ValueE> h;
        ValueT ti;
        ValueE ei;
        Comparison<Key> c;
        Node root;
        bool isNeedFix;
        Node lmax;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(ValueT ti, ValueE ei, Func<ValueT, ValueT, ValueT> f, Func<ValueT, ValueE, int, ValueT> g, Func<ValueE, ValueE, ValueE> h, Comparison<Key> c, bool ope = true)
        {
            this.ti = ti;
            this.ei = ei;
            this.f = f;
            this.g = g;
            this.h = h;
            this.c = c;
            this.ope = ope;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(ValueT ti, ValueE ei, Func<ValueT, ValueT, ValueT> f, Func<ValueT, ValueE, int, ValueT> g, Func<ValueE, ValueE, ValueE> h) : this(ti, ei, f, g, h, Comparer<Key>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        bool IsRed(Node n) => n != null && !n.isBlack;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        bool IsBlack(Node n) => n != null && n.isBlack;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        int Cnt(Node n) => n == null ? 0 : n.cnt;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Eval(Node n)
        {
            if (n == null || ei.Equals(n.lazy)) return;
            n.val = g(n.val, n.lazy, 1);
            if (!n.needRecalc) n.dat = g(n.dat, n.lazy, Cnt(n));
            if (n.left != null) n.left.lazy = h(n.left.lazy, n.lazy);
            if (n.right != null) n.right.lazy = h(n.right.lazy, n.lazy);
            n.lazy = ei;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Recalc(Node n)
        {
            if (n == null) return;
            Eval(n);
            if (!n.needRecalc) return;
            n.needRecalc = false;
            n.dat = n.val;
            if (n.left != null)
            {
                Recalc(n.left);
                n.dat = f(n.left.dat, n.dat);
            }
            if (n.right != null)
            {
                Recalc(n.right);
                n.dat = f(n.dat, n.right.dat);
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateL(Node n)
        {
            if (ope) { Eval(n); Eval(n.right); }
            Node m = n.right, t = m.left;
            m.left = n; n.right = t;
            n.cnt -= m.cnt - Cnt(t);
            m.cnt += n.cnt - Cnt(t);
            n.needRecalc = true; m.needRecalc = true;
            return m;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateR(Node n)
        {
            if (ope) { Eval(n); Eval(n.left); }
            Node m = n.left, t = m.right;
            m.right = n; n.left = t;
            n.cnt -= m.cnt - Cnt(t);
            m.cnt += n.cnt - Cnt(t);
            n.needRecalc = true; m.needRecalc = true;
            return m;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateLR(Node n)
        {
            n.left = RotateL(n.left);
            return RotateR(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateRL(Node n)
        {
            n.right = RotateR(n.right);
            return RotateL(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(Key key, ValueT val)
        {
            root = Add(root, key, val);
            root.isBlack = true;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Add(Node n, Key key, ValueT val)
        {
            if (n == null)
            {
                isNeedFix = true;
                return new Node() { key = key, val = val, dat = val, lazy = ei, cnt = 1 };
            }
            if (ope) Eval(n);
            if (c(key, n.key) < 0) n.left = Add(n.left, key, val);
            else n.right = Add(n.right, key, val);
            n.needRecalc = true;
            ++n.cnt;
            return Balance(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Balance(Node n)
        {
            if (!isNeedFix || !IsBlack(n)) return n;
            if (IsRed(n.left) && IsRed(n.left.left))
            {
                n = RotateR(n);
                n.left.isBlack = true;
            }
            else if (IsRed(n.left) && IsRed(n.left.right))
            {
                n = RotateLR(n);
                n.left.isBlack = true;
            }
            else if (IsRed(n.right) && IsRed(n.right.left))
            {
                n = RotateRL(n);
                n.right.isBlack = true;
            }
            else if (IsRed(n.right) && IsRed(n.right.right))
            {
                n = RotateL(n);
                n.right.isBlack = true;
            }
            else isNeedFix = false;
            return n;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(Key key)
        {
            root = Remove(root, key);
            if (root != null) root.isBlack = true;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Remove(Node n, Key key)
        {
            if (ope) Eval(n);
            --n.cnt;
            var r = c(key, n.key);
            if (r < 0)
            {
                n.left = Remove(n.left, key);
                n.needRecalc = true;
                return BalanceL(n);
            }
            if (r > 0)
            {
                n.right = Remove(n.right, key);
                n.needRecalc = true;
                return BalanceR(n);
            }
            if (n.left == null)
            {
                isNeedFix = n.isBlack;
                return n.right;
            }
            n.left = RemoveMax(n.left);
            n.key = lmax.key;
            n.val = lmax.val;
            n.needRecalc = true;
            return BalanceL(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RemoveMax(Node n)
        {
            if (ope) Eval(n);
            --n.cnt;
            if (n.right != null)
            {
                n.right = RemoveMax(n.right);
                n.needRecalc = true;
                return BalanceR(n);
            }
            lmax = n;
            isNeedFix = n.isBlack;
            return n.left;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node BalanceL(Node n)
        {
            if (!isNeedFix) return n;
            if (IsBlack(n.right) && IsRed(n.right.left))
            {
                var b = n.isBlack;
                n = RotateRL(n);
                n.isBlack = b;
                n.left.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.right) && IsRed(n.right.right))
            {
                var b = n.isBlack;
                n = RotateL(n);
                n.isBlack = b;
                n.right.isBlack = true;
                n.left.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.right))
            {
                isNeedFix = n.isBlack;
                n.isBlack = true;
                n.right.isBlack = false;
            }
            else
            {
                n = RotateL(n);
                n.isBlack = true;
                n.left.isBlack = false;
                n.left = BalanceL(n.left);
                isNeedFix = false;
            }
            return n;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node BalanceR(Node n)
        {
            if (!isNeedFix) return n;
            if (IsBlack(n.left) && IsRed(n.left.right))
            {
                var b = n.isBlack;
                n = RotateLR(n);
                n.isBlack = b; n.right.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.left) && IsRed(n.left.left))
            {
                var b = n.isBlack;
                n = RotateR(n);
                n.isBlack = b;
                n.left.isBlack = true;
                n.right.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.left))
            {
                isNeedFix = n.isBlack;
                n.isBlack = true;
                n.left.isBlack = false;
            }
            else
            {
                n = RotateR(n);
                n.isBlack = true;
                n.right.isBlack = false;
                n.right = BalanceR(n.right);
                isNeedFix = false;
            }
            return n;
        }
        public KeyValuePair<Key, ValueT> this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return At(root, i); }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        KeyValuePair<Key, ValueT> At(Node n, long i)
        {
            if (ope) Eval(n);
            if (n.left == null)
            {
                if (i == 0) return new KeyValuePair<Key, ValueT>(n.key, n.val);
                else return At(n.right, i - 1);
            }
            if (n.left.cnt == i) return new KeyValuePair<Key, ValueT>(n.key, n.val);
            if (n.left.cnt > i) return At(n.left, i);
            return At(n.right, i - n.left.cnt - 1);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(Key key)
        {
            var t = LowerBound(key);
            return t < Cnt(root) && c(At(root, t).Key, key) == 0;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(Key key) => UpperBound(root, key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        long UpperBound(Node n, Key key)
        {
            if (n == null) return 0;
            var r = c(key, n.key);
            if (r < 0) return UpperBound(n.left, key);
            return Cnt(n.left) + 1 + UpperBound(n.right, key);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(Key key) => LowerBound(root, key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        long LowerBound(Node n, Key key)
        {
            if (n == null) return 0;
            var r = c(key, n.key);
            if (r <= 0) return LowerBound(n.left, key);
            return Cnt(n.left) + 1 + LowerBound(n.right, key);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, ValueT> Min()
        {
            Node n = root.left, p = root;
            while (n != null)
            {
                p = n;
                if (ope) Eval(p);
                n = n.left;
            }
            return new KeyValuePair<Key, ValueT>(p.key, p.val);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, ValueT> Max()
        {
            Node n = root.right, p = root;
            while (n != null)
            {
                p = n;
                if (ope) Eval(p);
                n = n.right;
            }
            return new KeyValuePair<Key, ValueT>(p.key, p.val);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Update(long l, long r, ValueE val) => Update(root, l, r, val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Update(Node n, long l, long r, ValueE val)
        {
            if (n == null) return;
            Eval(n);
            n.needRecalc = true;
            var lc = Cnt(n.left);
            if (lc < l) Update(n.right, l - lc - 1, r - lc - 1, val);
            else if (r <= lc) Update(n.left, l, r, val);
            else if (l <= 0 && Cnt(n) <= r) n.lazy = val;
            else
            {
                n.val = g(n.val, val, 1);
                if (l < lc) Update(n.left, l, lc, val);
                if (lc + 1 < r) Update(n.right, 0, r - lc - 1, val);
            }
            return;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public ValueT Query(long l, long r) => Query(root, l, r);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        ValueT Query(Node n, long l, long r)
        {
            var v1 = ti; var v2 = ti; var v3 = ti;
            if (n == null) return ti;
            Eval(n);
            var lc = Cnt(n.left);
            if (lc < l) v3 = Query(n.right, l - lc - 1, r - lc - 1);
            else if (r <= lc) v1 = Query(n.left, l, r);
            else if (l <= 0 && Cnt(n) <= r)
            {
                Recalc(n);
                v2 = n.dat;
            }
            else
            {
                if (l < lc) v1 = Query(n.left, l, lc);
                if (lc + 1 < r) v3 = Query(n.right, 0, r - lc - 1);
                v2 = n.val;
            }
            return f(f(v1, v2), v3);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => root != null;
        public long Count => Cnt(root);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<KeyValuePair<Key, ValueT>> List() => L(root);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        IEnumerable<KeyValuePair<Key, ValueT>> L(Node n)
        {
            if (n == null) yield break;
            foreach (var i in L(n.left)) yield return i;
            yield return new KeyValuePair<Key, ValueT>(n.key, n.val);
            foreach (var i in L(n.right)) yield return i;
        }
    }
    class LIB_RedBlackTree<Key, Value>
    {
        LIB_RedBlackTree<Key, Value, int> tree;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(Comparison<Key> c) { tree = new LIB_RedBlackTree<Key, Value, int>(default(Value), 0, null, null, null, c, false); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree() : this(Comparer<Key>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(Key key, Value val) => tree.Add(key, val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(Key key) => tree.Remove(key);
        public KeyValuePair<Key, Value> this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return tree[i]; }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(Key key) => tree.ContainsKey(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(Key key) => tree.UpperBound(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(Key key) => tree.LowerBound(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, Value> Min() => tree.Min();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, Value> Max() => tree.Max();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => tree.Any();
        public long Count => tree.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<KeyValuePair<Key, Value>> List() => tree.List();
    }
    class LIB_RedBlackTree<T>
    {
        LIB_RedBlackTree<T, int, int> tree;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(Comparison<T> c) { tree = new LIB_RedBlackTree<T, int, int>(0, 0, null, null, null, c, false); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree() : this(Comparer<T>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(T val) => tree.Add(val, 0);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(T val) => tree.Remove(val);
        public T this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return tree[i].Key; }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(T val) => tree.ContainsKey(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(T val) => tree.UpperBound(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(T val) => tree.LowerBound(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Min() => tree.Min().Key;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Max() => tree.Max().Key;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => tree.Any();
        public long Count => tree.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<T> List() => tree.List().Select(e => e.Key);
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ProblemD
    {
        static bool SAIKI = false;
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var n = (int)NN;
            var m = (int)NN;
            var q = (int)NN;
            var pList = NNList(n);
            var ab = Repeat(0, m).Select(_ => new { a = (int)NN - 1, b = (int)NN - 1 }).ToArray();
            var query = Repeat(0, q).Select(_ => new { t = (int)NN, param = (int)NN }).ToArray();
            var uf = new LIB_UnionFind<LIB_RedBlackTree<long>>(Range(0, n).Select(e =>
            {
                var ret = new LIB_RedBlackTree<long>();
                ret.Add(pList[e]);
                return ret;
            }), (x, y) =>
            {
                var rt = LIB_UnionFind.RootVtx.Y;
                //if (x.Count > y.Count) { var t = x; x = y; y = t; rt = LIB_UnionFind.RootVtx.X; }
                foreach (var item in x.List()) y.Add(item);
                return (rt, y);
            }, (x, y) =>
            {
                foreach (var item in y.List().ToArray())
                {
                    if (x.ContainsKey(item)) x.Remove(item);
                    else y.Remove(item);
                }
                return (x, y);
            });
            var deleted = new bool[m];
            foreach (var item in query)
            {
                if (item.t == 2) deleted[item.param - 1] = true;
            }
            for (var i = 0; i < m; i++)
            {
                if (!deleted[i]) uf.Unite(ab[i].a, ab[i].b);
            }
            foreach (var item in query.Reverse())
            {
                if (item.t == 2) uf.Unite(ab[item.param - 1].a, ab[item.param - 1].b);
            }
            foreach (var item in query)
            {
                if (item.t == 1)
                {
                    var set = uf.Calc(item.param - 1);
                    var value = 0L;
                    if (set.Count > 0)
                    {
                        value = set.Max();
                        set.Remove(value);
                    }
                    Console.WriteLine(value);
                }
                else uf.Undo();
            }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static LIB_FastIO fastio = new LIB_FastIODebug();
        static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }
        static long NN => fastio.Long();
        static double ND => fastio.Double();
        static string NS => fastio.Scan();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);
        static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);
        static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
        static bool Chmax<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }
        static bool Chmin<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }
    }
}
namespace Library {
    class LIB_RedBlackTree
    {
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeMin() => new LIB_RedBlackTree<long, long, long>(long.MaxValue, long.MinValue + 100, Math.Min, (x, y, c) => y, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeMin() => new LIB_RedBlackTree<long, long, long>(long.MaxValue, 0, Math.Min, (x, y, c) => x + y, (x, y) => x + y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeMax() => new LIB_RedBlackTree<long, long, long>(long.MinValue, long.MaxValue - 100, Math.Max, (x, y, c) => y, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeMax() => new LIB_RedBlackTree<long, long, long>(long.MinValue, 0, Math.Max, (x, y, c) => x + y, (x, y) => x + y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeSum() => new LIB_RedBlackTree<long, long, long>(0, long.MaxValue, (x, y) => x + y, (x, y, c) => y * c, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeSum() => new LIB_RedBlackTree<long, long, long>(0, 0, (x, y) => x + y, (x, y, c) => x + y * c, (x, y) => x + y);
    }
    class LIB_RedBlackTree<Key, ValueT, ValueE> where ValueE : IEquatable<ValueE>
    {
        bool ope;
        class Node
        {
            public Node left;
            public Node right;
            public Key key;
            public ValueT val;
            public ValueT dat;
            public ValueE lazy;
            public bool isBlack;
            public int cnt;
            public bool needRecalc;
        }
        Func<ValueT, ValueT, ValueT> f;
        Func<ValueT, ValueE, int, ValueT> g;
        Func<ValueE, ValueE, ValueE> h;
        ValueT ti;
        ValueE ei;
        Comparison<Key> c;
        Node root;
        bool isNeedFix;
        Node lmax;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(ValueT ti, ValueE ei, Func<ValueT, ValueT, ValueT> f, Func<ValueT, ValueE, int, ValueT> g, Func<ValueE, ValueE, ValueE> h, Comparison<Key> c, bool ope = true)
        {
            this.ti = ti;
            this.ei = ei;
            this.f = f;
            this.g = g;
            this.h = h;
            this.c = c;
            this.ope = ope;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(ValueT ti, ValueE ei, Func<ValueT, ValueT, ValueT> f, Func<ValueT, ValueE, int, ValueT> g, Func<ValueE, ValueE, ValueE> h) : this(ti, ei, f, g, h, Comparer<Key>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        bool IsRed(Node n) => n != null && !n.isBlack;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        bool IsBlack(Node n) => n != null && n.isBlack;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        int Cnt(Node n) => n == null ? 0 : n.cnt;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Eval(Node n)
        {
            if (n == null || ei.Equals(n.lazy)) return;
            n.val = g(n.val, n.lazy, 1);
            if (!n.needRecalc) n.dat = g(n.dat, n.lazy, Cnt(n));
            if (n.left != null) n.left.lazy = h(n.left.lazy, n.lazy);
            if (n.right != null) n.right.lazy = h(n.right.lazy, n.lazy);
            n.lazy = ei;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Recalc(Node n)
        {
            if (n == null) return;
            Eval(n);
            if (!n.needRecalc) return;
            n.needRecalc = false;
            n.dat = n.val;
            if (n.left != null)
            {
                Recalc(n.left);
                n.dat = f(n.left.dat, n.dat);
            }
            if (n.right != null)
            {
                Recalc(n.right);
                n.dat = f(n.dat, n.right.dat);
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateL(Node n)
        {
            if (ope) { Eval(n); Eval(n.right); }
            Node m = n.right, t = m.left;
            m.left = n; n.right = t;
            n.cnt -= m.cnt - Cnt(t);
            m.cnt += n.cnt - Cnt(t);
            n.needRecalc = true; m.needRecalc = true;
            return m;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateR(Node n)
        {
            if (ope) { Eval(n); Eval(n.left); }
            Node m = n.left, t = m.right;
            m.right = n; n.left = t;
            n.cnt -= m.cnt - Cnt(t);
            m.cnt += n.cnt - Cnt(t);
            n.needRecalc = true; m.needRecalc = true;
            return m;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateLR(Node n)
        {
            n.left = RotateL(n.left);
            return RotateR(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateRL(Node n)
        {
            n.right = RotateR(n.right);
            return RotateL(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(Key key, ValueT val)
        {
            root = Add(root, key, val);
            root.isBlack = true;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Add(Node n, Key key, ValueT val)
        {
            if (n == null)
            {
                isNeedFix = true;
                return new Node() { key = key, val = val, dat = val, lazy = ei, cnt = 1 };
            }
            if (ope) Eval(n);
            if (c(key, n.key) < 0) n.left = Add(n.left, key, val);
            else n.right = Add(n.right, key, val);
            n.needRecalc = true;
            ++n.cnt;
            return Balance(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Balance(Node n)
        {
            if (!isNeedFix || !IsBlack(n)) return n;
            if (IsRed(n.left) && IsRed(n.left.left))
            {
                n = RotateR(n);
                n.left.isBlack = true;
            }
            else if (IsRed(n.left) && IsRed(n.left.right))
            {
                n = RotateLR(n);
                n.left.isBlack = true;
            }
            else if (IsRed(n.right) && IsRed(n.right.left))
            {
                n = RotateRL(n);
                n.right.isBlack = true;
            }
            else if (IsRed(n.right) && IsRed(n.right.right))
            {
                n = RotateL(n);
                n.right.isBlack = true;
            }
            else isNeedFix = false;
            return n;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(Key key)
        {
            root = Remove(root, key);
            if (root != null) root.isBlack = true;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Remove(Node n, Key key)
        {
            if (ope) Eval(n);
            --n.cnt;
            var r = c(key, n.key);
            if (r < 0)
            {
                n.left = Remove(n.left, key);
                n.needRecalc = true;
                return BalanceL(n);
            }
            if (r > 0)
            {
                n.right = Remove(n.right, key);
                n.needRecalc = true;
                return BalanceR(n);
            }
            if (n.left == null)
            {
                isNeedFix = n.isBlack;
                return n.right;
            }
            n.left = RemoveMax(n.left);
            n.key = lmax.key;
            n.val = lmax.val;
            n.needRecalc = true;
            return BalanceL(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RemoveMax(Node n)
        {
            if (ope) Eval(n);
            --n.cnt;
            if (n.right != null)
            {
                n.right = RemoveMax(n.right);
                n.needRecalc = true;
                return BalanceR(n);
            }
            lmax = n;
            isNeedFix = n.isBlack;
            return n.left;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node BalanceL(Node n)
        {
            if (!isNeedFix) return n;
            if (IsBlack(n.right) && IsRed(n.right.left))
            {
                var b = n.isBlack;
                n = RotateRL(n);
                n.isBlack = b;
                n.left.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.right) && IsRed(n.right.right))
            {
                var b = n.isBlack;
                n = RotateL(n);
                n.isBlack = b;
                n.right.isBlack = true;
                n.left.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.right))
            {
                isNeedFix = n.isBlack;
                n.isBlack = true;
                n.right.isBlack = false;
            }
            else
            {
                n = RotateL(n);
                n.isBlack = true;
                n.left.isBlack = false;
                n.left = BalanceL(n.left);
                isNeedFix = false;
            }
            return n;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node BalanceR(Node n)
        {
            if (!isNeedFix) return n;
            if (IsBlack(n.left) && IsRed(n.left.right))
            {
                var b = n.isBlack;
                n = RotateLR(n);
                n.isBlack = b; n.right.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.left) && IsRed(n.left.left))
            {
                var b = n.isBlack;
                n = RotateR(n);
                n.isBlack = b;
                n.left.isBlack = true;
                n.right.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.left))
            {
                isNeedFix = n.isBlack;
                n.isBlack = true;
                n.left.isBlack = false;
            }
            else
            {
                n = RotateR(n);
                n.isBlack = true;
                n.right.isBlack = false;
                n.right = BalanceR(n.right);
                isNeedFix = false;
            }
            return n;
        }
        public KeyValuePair<Key, ValueT> this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return At(root, i); }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        KeyValuePair<Key, ValueT> At(Node n, long i)
        {
            if (ope) Eval(n);
            if (n.left == null)
            {
                if (i == 0) return new KeyValuePair<Key, ValueT>(n.key, n.val);
                else return At(n.right, i - 1);
            }
            if (n.left.cnt == i) return new KeyValuePair<Key, ValueT>(n.key, n.val);
            if (n.left.cnt > i) return At(n.left, i);
            return At(n.right, i - n.left.cnt - 1);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(Key key)
        {
            var t = LowerBound(key);
            return t < Cnt(root) && c(At(root, t).Key, key) == 0;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(Key key) => UpperBound(root, key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        long UpperBound(Node n, Key key)
        {
            if (n == null) return 0;
            var r = c(key, n.key);
            if (r < 0) return UpperBound(n.left, key);
            return Cnt(n.left) + 1 + UpperBound(n.right, key);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(Key key) => LowerBound(root, key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        long LowerBound(Node n, Key key)
        {
            if (n == null) return 0;
            var r = c(key, n.key);
            if (r <= 0) return LowerBound(n.left, key);
            return Cnt(n.left) + 1 + LowerBound(n.right, key);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, ValueT> Min()
        {
            Node n = root.left, p = root;
            while (n != null)
            {
                p = n;
                if (ope) Eval(p);
                n = n.left;
            }
            return new KeyValuePair<Key, ValueT>(p.key, p.val);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, ValueT> Max()
        {
            Node n = root.right, p = root;
            while (n != null)
            {
                p = n;
                if (ope) Eval(p);
                n = n.right;
            }
            return new KeyValuePair<Key, ValueT>(p.key, p.val);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Update(long l, long r, ValueE val) => Update(root, l, r, val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Update(Node n, long l, long r, ValueE val)
        {
            if (n == null) return;
            Eval(n);
            n.needRecalc = true;
            var lc = Cnt(n.left);
            if (lc < l) Update(n.right, l - lc - 1, r - lc - 1, val);
            else if (r <= lc) Update(n.left, l, r, val);
            else if (l <= 0 && Cnt(n) <= r) n.lazy = val;
            else
            {
                n.val = g(n.val, val, 1);
                if (l < lc) Update(n.left, l, lc, val);
                if (lc + 1 < r) Update(n.right, 0, r - lc - 1, val);
            }
            return;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public ValueT Query(long l, long r) => Query(root, l, r);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        ValueT Query(Node n, long l, long r)
        {
            var v1 = ti; var v2 = ti; var v3 = ti;
            if (n == null) return ti;
            Eval(n);
            var lc = Cnt(n.left);
            if (lc < l) v3 = Query(n.right, l - lc - 1, r - lc - 1);
            else if (r <= lc) v1 = Query(n.left, l, r);
            else if (l <= 0 && Cnt(n) <= r)
            {
                Recalc(n);
                v2 = n.dat;
            }
            else
            {
                if (l < lc) v1 = Query(n.left, l, lc);
                if (lc + 1 < r) v3 = Query(n.right, 0, r - lc - 1);
                v2 = n.val;
            }
            return f(f(v1, v2), v3);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => root != null;
        public long Count => Cnt(root);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<KeyValuePair<Key, ValueT>> List() => L(root);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        IEnumerable<KeyValuePair<Key, ValueT>> L(Node n)
        {
            if (n == null) yield break;
            foreach (var i in L(n.left)) yield return i;
            yield return new KeyValuePair<Key, ValueT>(n.key, n.val);
            foreach (var i in L(n.right)) yield return i;
        }
    }
    class LIB_RedBlackTree<Key, Value>
    {
        LIB_RedBlackTree<Key, Value, int> tree;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(Comparison<Key> c) { tree = new LIB_RedBlackTree<Key, Value, int>(default(Value), 0, null, null, null, c, false); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree() : this(Comparer<Key>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(Key key, Value val) => tree.Add(key, val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(Key key) => tree.Remove(key);
        public KeyValuePair<Key, Value> this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return tree[i]; }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(Key key) => tree.ContainsKey(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(Key key) => tree.UpperBound(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(Key key) => tree.LowerBound(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, Value> Min() => tree.Min();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, Value> Max() => tree.Max();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => tree.Any();
        public long Count => tree.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<KeyValuePair<Key, Value>> List() => tree.List();
    }
    class LIB_RedBlackTree<T>
    {
        LIB_RedBlackTree<T, int, int> tree;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(Comparison<T> c) { tree = new LIB_RedBlackTree<T, int, int>(0, 0, null, null, null, c, false); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree() : this(Comparer<T>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(T val) => tree.Add(val, 0);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(T val) => tree.Remove(val);
        public T this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return tree[i].Key; }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(T val) => tree.ContainsKey(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(T val) => tree.UpperBound(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(T val) => tree.LowerBound(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Min() => tree.Min().Key;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Max() => tree.Max().Key;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => tree.Any();
        public long Count => tree.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<T> List() => tree.List().Select(e => e.Key);
    }
    class LIB_UnionFind<T>
    {
        int[] d;
        Stack<(int, int)> h;
        T[] v;
        Func<T, T, (LIB_UnionFind.RootVtx, T)> f;
        Func<T, T, (T, T)> rf;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(IEnumerable<T> s, Func<T, T, (LIB_UnionFind.RootVtx, T)> func, Func<T, T, (T, T)> revFunc)
        {
            v = s.ToArray();
            d = Enumerable.Repeat(-1, v.Length).ToArray();
            f = func;
            rf = revFunc;
            h = new Stack<(int, int)>();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Unite(long x, long y)
        {
            x = Root(x);
            y = Root(y);
            if (x != y)
            {
                var (root, value) = f(v[x], v[y]);
                if (root == LIB_UnionFind.RootVtx.X)
                {
                    h.Push(((int)y, d[y]));
                    h.Push(((int)x, d[x]));
                    d[x] = d[x] + d[y];
                    d[y] = (int)x;
                    v[x] = value;
                }
                else
                {
                    h.Push(((int)x, d[x]));
                    h.Push(((int)y, d[y]));
                    d[y] = d[x] + d[y];
                    d[x] = (int)y;
                    v[y] = value;
                }
            }
            return x != y;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Undo()
        {
            var pop1 = h.Pop();
            var pop2 = h.Pop();
            if (pop1.Item1 == pop2.Item1) return;
            d[pop1.Item1] = pop1.Item2;
            d[pop2.Item1] = pop2.Item2;
            (v[pop1.Item1], v[pop2.Item1]) = rf(v[pop1.Item1], v[pop2.Item1]);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool IsSame(long x, long y) => Root(x) == Root(y);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Root(long x) => d[x] < 0 ? x : d[x] = (int)Root(d[x]);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Count(long x) => -d[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Calc(long x) => v[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Snapshot() => h.Clear();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Rollback()
        {
            while (h.Count > 0) Undo();
        }
    }
    class LIB_UnionFind : LIB_UnionFind<int>
    {
        public enum RootVtx { X, Y };
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(long n) : base(Enumerable.Repeat(0, (int)n), (x, y) => (RootVtx.X, x + y), (x, y) =>
        {
            if (x < y) return (x, y - x);
            else return (x - y, y);
        })
        { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        new private void Calc(long x) { }
    }
    class LIB_FastIO
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIO() { str = Console.OpenStandardInput(); }
        readonly Stream str;
        readonly byte[] buf = new byte[2048];
        int len, ptr;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        byte read()
        {
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 2048)) <= 0)
                {
                    return 0;
                }
            }
            return buf[ptr++];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = (ret << 3) + (ret << 1) + b - '0';
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
    class LIB_FastIODebug : LIB_FastIO
    {
        Queue<string> param = new Queue<string>();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIODebug() { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string Scan() => NextString();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override long Long() => long.Parse(NextString());
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override double Double() => double.Parse(NextString());
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ProblemD
    {
        static bool SAIKI = false;
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var n = (int)NN;
            var m = (int)NN;
            var q = (int)NN;
            var pList = NNList(n);
            var ab = Repeat(0, m).Select(_ => new { a = (int)NN - 1, b = (int)NN - 1 }).ToArray();
            var query = Repeat(0, q).Select(_ => new { t = (int)NN, param = (int)NN }).ToArray();
            var graph = Repeat(0, n).Select(_ => new List<int>()).ToArray();
            var uf = new LIB_UnionFind(n);
            var deleted = new bool[m];
            foreach (var item in query)
            {
                if (item.t == 2) deleted[item.param - 1] = true;
            }
            for (var i = 0; i < m; i++)
            {
                if (!deleted[i])
                {
                    if (uf.Unite(ab[i].a, ab[i].b))
                    {
                        graph[ab[i].a].Add(ab[i].b);
                        graph[ab[i].b].Add(ab[i].a);
                    }
                }
            }
            foreach (var item in query.Reverse())
            {
                if (item.t == 2)
                {
                    var i = item.param - 1;
                    if (uf.Unite(ab[i].a, ab[i].b))
                    {
                        graph[ab[i].a].Add(ab[i].b);
                        graph[ab[i].b].Add(ab[i].a);
                    }
                }
            }
            var param = new int[n];
            var qList = new List<LIB_PriorityQueue<int, int>>();
            var used = new bool[n];
            {
                var done = new bool[n];
                for (var i = 0; i < n; i++)
                {
                    if (!done[i])
                    {
                        var c = qList.Count();
                        var tmpq = new LIB_PriorityQueue<int, int>(false);
                        qList.Add(tmpq);
                        var que = new Queue<int>();
                        que.Enqueue(i);
                        done[i] = true;
                        param[i] = c;
                        while (que.Count > 0)
                        {
                            var v = que.Dequeue();
                            foreach (var item in graph[v])
                            {
                                if (done[item]) continue;
                                done[item] = true;
                                param[item] = c;
                                que.Enqueue(item);
                            }
                        }
                    }
                    qList[param[i]].Push((int)pList[i], i);
                }
            }
            foreach (var item in query)
            {
                if (item.t == 1)
                {
                    var v = item.param - 1;
                    var p = param[v];
                    var que = qList[p];
                    var value = 0L;
                    while (que.Count > 0)
                    {
                        if (used[que.Peek.Value] || p != param[que.Peek.Value]) que.Pop();
                        else
                        {
                            used[que.Peek.Value] = true;
                            value = que.Pop().Key;
                            break;
                        }
                    }
                    Console.WriteLine(value);
                }
                else
                {
                    var leftV = ab[item.param - 1].a;
                    var rightV = ab[item.param - 1].b;
                    if (!graph[leftV].Contains(rightV)) continue;
                    var leftQ = new Queue<(int, int)>();
                    var rightQ = new Queue<(int, int)>();
                    var color = param[leftV];
                    var procV = leftV;
                    var lidx = 0;
                    var ridx = 0;
                    var lv = leftV;
                    var rv = rightV;
                    var lp = rightV;
                    var rp = leftV;
                    var exit = false;
                    var leftVs = new List<int>();
                    var rightVs = new List<int>();
                    leftVs.Add(leftV);
                    rightVs.Add(rightV);
                    var procVs = new List<int>();
                    while (true)
                    {
                        var leftOK = false;
                        while (true)
                        {
                            while (graph[lv].Count > lidx)
                            {
                                var v = graph[lv][lidx++];
                                if (v == lp) continue;
                                leftQ.Enqueue((v, lv));
                                leftVs.Add(v);
                                leftOK = true;
                                break;
                            }
                            if (leftOK) break;
                            if (leftQ.Count == 0)
                            {
                                procVs = leftVs;
                                exit = true;
                                break;
                            }
                            var pop = leftQ.Dequeue();
                            lv = pop.Item1;
                            lp = pop.Item2;
                            lidx = 0;
                        }
                        if (exit) break;
                        var rightOK = false;
                        while (true)
                        {
                            while (graph[rv].Count > ridx)
                            {
                                var v = graph[rv][ridx++];
                                if (v == rp) continue;
                                rightQ.Enqueue((v, rv));
                                rightVs.Add(v);
                                rightOK = true;
                                break;
                            }
                            if (rightOK) break;
                            if (rightQ.Count == 0)
                            {
                                procV = rightV;
                                procVs = rightVs;
                                exit = true;
                                break;
                            }
                            var pop = rightQ.Dequeue();
                            rv = pop.Item1;
                            rp = pop.Item2;
                            ridx = 0;
                        }
                        if (exit) break;
                    }
                    var procColorTo = qList.Count;
                    var tmpq = new LIB_PriorityQueue<int, int>(false);
                    qList.Add(tmpq);
                    foreach (var item2 in procVs)
                    {
                        if (!used[item2]) tmpq.Push((int)pList[item2], item2);
                        param[item2] = procColorTo;
                    }
                }
            }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static LIB_FastIO fastio = new LIB_FastIODebug();
        static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }
        static long NN => fastio.Long();
        static double ND => fastio.Double();
        static string NS => fastio.Scan();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);
        static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);
        static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
        static bool Chmax<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }
        static bool Chmin<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }
    }
}
namespace Library {
    class LIB_UnionFind<T>
    {
        int[] d;
        T[] v;
        Func<T, T, T> f;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(IEnumerable<T> s, Func<T, T, T> func)
        {
            v = s.ToArray();
            d = Enumerable.Repeat(-1, v.Length).ToArray();
            f = func;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Unite(long x, long y)
        {
            x = Root(x);
            y = Root(y);
            if (x != y)
            {
                d[x] = d[x] + d[y];
                v[x] = f(v[x], v[y]);
                d[y] = (int)x;
            }
            return x != y;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool IsSame(long x, long y) => Root(x) == Root(y);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Root(long x) => d[x] < 0 ? x : d[x] = (int)Root(d[x]);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Count(long x) => -d[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Calc(long x) => v[Root(x)];
    }
    class LIB_UnionFind : LIB_UnionFind<int>
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(long n) : base(Enumerable.Repeat(0, (int)n), (x, y) => x + y) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        new private void Calc(long x) { }
    }
    class LIB_PriorityQueue
    {
        long[] heap;
        int[] dat;
        public long Count
        {
            get;
            private set;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue()
        {
            heap = new long[128];
            dat = new int[128];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(long key, int val)
        {
            if (Count == heap.Length) Expand();
            var i = Count++;
            heap[i] = key;
            dat[i] = val;
            while (i > 0)
            {
                var ni = (i - 1) / 2;
                if (key >= heap[ni]) break;
                heap[i] = heap[ni];
                dat[i] = dat[ni];
                i = ni;
            }
            heap[i] = key;
            dat[i] = val;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<long, int> Pop()
        {
            var ret = new KeyValuePair<long, int>(heap[0], dat[0]);
            var key = heap[--Count];
            var val = dat[Count];
            if (Count == 0) return ret;
            var i = 0; while ((i << 1) + 1 < Count)
            {
                var i1 = (i << 1) + 1;
                var i2 = (i << 1) + 2;
                if (i2 < Count && heap[i1] > heap[i2]) i1 = i2;
                if (key <= heap[i1]) break;
                heap[i] = heap[i1];
                dat[i] = dat[i1];
                i = i1;
            }
            heap[i] = key;
            dat[i] = val;
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Expand()
        {
            var tmp = new long[Count << 1];
            for (var i = 0; i < heap.Length; ++i) tmp[i] = heap[i];
            heap = tmp;
            var tmp2 = new int[Count << 1];
            for (var i = 0; i < dat.Length; ++i) tmp2[i] = dat[i];
            dat = tmp2;
        }
    }
    class LIB_PriorityQueue<T>
    {
        T[] heap;
        Comparison<T> comp;
        public T Peek => heap[0];
        public long Count
        {
            get;
            private set;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, Comparison<T> cmp, bool asc = true)
        {
            heap = new T[cap];
            comp = asc ? cmp : (x, y) => cmp(y, x);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(Comparison<T> cmp, bool asc = true)
        {
            heap = new T[128];
            comp = asc ? cmp : (x, y) => cmp(y, x);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, bool asc = true) : this(cap, Comparer<T>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(bool asc = true) : this(Comparer<T>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(T val)
        {
            if (Count == heap.Length) Expand();
            var i = Count++;
            heap[i] = val;
            while (i > 0)
            {
                var ni = (i - 1) / 2;
                if (comp(val, heap[ni]) >= 0) break;
                heap[i] = heap[ni];
                i = ni;
            }
            heap[i] = val;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Pop()
        {
            var ret = heap[0];
            var val = heap[--Count];
            if (Count == 0) return ret;
            var i = 0; while ((i << 1) + 1 < Count)
            {
                var i1 = (i << 1) + 1;
                var i2 = (i << 1) + 2;
                if (i2 < Count && comp(heap[i1], heap[i2]) > 0) i1 = i2;
                if (comp(val, heap[i1]) <= 0) break;
                heap[i] = heap[i1]; i = i1;
            }
            heap[i] = val;
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Expand()
        {
            var tmp = new T[Count << 1];
            for (var i = 0; i < heap.Length; ++i) tmp[i] = heap[i];
            heap = tmp;
        }
    }
    class LIB_PriorityQueue<TK, TV>
    {
        LIB_PriorityQueue<KeyValuePair<TK, TV>> q;
        public KeyValuePair<TK, TV> Peek => q.Peek;
        public long Count => q.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, Comparison<TK> cmp, bool asc = true)
        {
            q = new LIB_PriorityQueue<KeyValuePair<TK, TV>>(cap, (x, y) => cmp(x.Key, y.Key), asc);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(Comparison<TK> cmp, bool asc = true)
        {
            q = new LIB_PriorityQueue<KeyValuePair<TK, TV>>((x, y) => cmp(x.Key, y.Key), asc);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, bool asc = true) : this(cap, Comparer<TK>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(bool asc = true) : this(Comparer<TK>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(TK k, TV v) => q.Push(new KeyValuePair<TK, TV>(k, v));
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<TK, TV> Pop() => q.Pop();
    }
    class LIB_FastIO
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIO() { str = Console.OpenStandardInput(); }
        readonly Stream str;
        readonly byte[] buf = new byte[2048];
        int len, ptr;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        byte read()
        {
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 2048)) <= 0)
                {
                    return 0;
                }
            }
            return buf[ptr++];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = (ret << 3) + (ret << 1) + b - '0';
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
    class LIB_FastIODebug : LIB_FastIO
    {
        Queue<string> param = new Queue<string>();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIODebug() { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string Scan() => NextString();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override long Long() => long.Parse(NextString());
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override double Double() => double.Parse(NextString());
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ProblemD
    {
        static bool SAIKI = false;
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var n = (int)NN;
            var m = (int)NN;
            var q = (int)NN;
            var pList = NNList(n);
            var ab = Repeat(0, m).Select(_ => new { a = (int)NN - 1, b = (int)NN - 1 }).ToArray();
            var query = Repeat(0, q).Select(_ => new { t = (int)NN, param = (int)NN }).ToArray();
            var graph = Repeat(0, n).Select(_ => new List<int>()).ToArray();
            var uf = new LIB_UnionFind(n);
            var deleted = new bool[m];
            foreach (var item in query)
            {
                if (item.t == 2) deleted[item.param - 1] = true;
            }
            for (var i = 0; i < m; i++)
            {
                if (!deleted[i])
                {
                    if (uf.Unite(ab[i].a, ab[i].b))
                    {
                        graph[ab[i].a].Add(ab[i].b);
                        graph[ab[i].b].Add(ab[i].a);
                    }
                }
            }
            foreach (var item in query.Reverse())
            {
                if (item.t == 2)
                {
                    var i = item.param - 1;
                    if (uf.Unite(ab[i].a, ab[i].b))
                    {
                        graph[ab[i].a].Add(ab[i].b);
                        graph[ab[i].b].Add(ab[i].a);
                    }
                }
            }
            var param = new int[n];
            var qList = new List<LIB_PriorityQueue<int, int>>();
            var used = new bool[n];
            {
                var done = new bool[n];
                for (var i = 0; i < n; i++)
                {
                    if (!done[i])
                    {
                        var c = qList.Count();
                        var tmpq = new LIB_PriorityQueue<int, int>(false);
                        qList.Add(tmpq);
                        var que = new Queue<int>();
                        que.Enqueue(i);
                        done[i] = true;
                        param[i] = c;
                        while (que.Count > 0)
                        {
                            var v = que.Dequeue();
                            foreach (var item in graph[v])
                            {
                                if (done[item]) continue;
                                done[item] = true;
                                param[item] = c;
                                que.Enqueue(item);
                            }
                        }
                    }
                    qList[param[i]].Push((int)pList[i], i);
                }
            }
            foreach (var item in query)
            {
                if (item.t == 1)
                {
                    var v = item.param - 1;
                    var p = param[v];
                    var que = qList[p];
                    var value = 0L;
                    while (que.Count > 0)
                    {
                        if (used[que.Peek.Value] || p != param[que.Peek.Value]) que.Pop();
                        else
                        {
                            used[que.Peek.Value] = true;
                            value = que.Pop().Key;
                            break;
                        }
                    }
                    Console.WriteLine(value);
                }
                else
                {
                    var leftV = ab[item.param - 1].a;
                    var rightV = ab[item.param - 1].b;
                    if (!graph[leftV].Contains(rightV)) continue;
                    var leftQ = new Queue<(int, int)>();
                    var rightQ = new Queue<(int, int)>();
                    var color = param[leftV];
                    var procV = leftV;
                    var lidx = 0;
                    var ridx = 0;
                    var lv = leftV;
                    var rv = rightV;
                    var lp = rightV;
                    var rp = leftV;
                    var exit = false;
                    var leftVs = new List<int>();
                    var rightVs = new List<int>();
                    leftVs.Add(leftV);
                    rightVs.Add(rightV);
                    var procVs = new List<int>();
                    while (true)
                    {
                        var leftOK = false;
                        while (true)
                        {
                            while (graph[lv].Count > lidx)
                            {
                                var v = graph[lv][lidx++];
                                if (v == lp) continue;
                                leftQ.Enqueue((v, lv));
                                leftVs.Add(v);
                                leftOK = true;
                                break;
                            }
                            if (leftOK) break;
                            if (leftQ.Count == 0)
                            {
                                procVs = leftVs;
                                exit = true;
                                break;
                            }
                            var pop = leftQ.Dequeue();
                            lv = pop.Item1;
                            lp = pop.Item2;
                            lidx = 0;
                        }
                        if (exit) break;
                        var rightOK = false;
                        while (true)
                        {
                            while (graph[rv].Count > ridx)
                            {
                                var v = graph[rv][ridx++];
                                if (v == rp) continue;
                                rightQ.Enqueue((v, rv));
                                rightVs.Add(v);
                                rightOK = true;
                                break;
                            }
                            if (rightOK) break;
                            if (rightQ.Count == 0)
                            {
                                procV = rightV;
                                procVs = rightVs;
                                exit = true;
                                break;
                            }
                            var pop = rightQ.Dequeue();
                            rv = pop.Item1;
                            rp = pop.Item2;
                            ridx = 0;
                        }
                        if (exit) break;
                    }
                    var procColorFrom = param[procV];
                    var procColorTo = qList.Count;
                    var tmpq = new LIB_PriorityQueue<int, int>(false);
                    qList.Add(tmpq);
                    foreach (var item2 in procVs)
                    {
                        tmpq.Push((int)pList[item2], item2);
                        param[item2] = procColorTo;
                    }
                }
            }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static LIB_FastIO fastio = new LIB_FastIODebug();
        static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }
        static long NN => fastio.Long();
        static double ND => fastio.Double();
        static string NS => fastio.Scan();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);
        static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);
        static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
        static bool Chmax<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }
        static bool Chmin<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }
    }
}
namespace Library {
    class LIB_PriorityQueue
    {
        long[] heap;
        int[] dat;
        public long Count
        {
            get;
            private set;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue()
        {
            heap = new long[128];
            dat = new int[128];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(long key, int val)
        {
            if (Count == heap.Length) Expand();
            var i = Count++;
            heap[i] = key;
            dat[i] = val;
            while (i > 0)
            {
                var ni = (i - 1) / 2;
                if (key >= heap[ni]) break;
                heap[i] = heap[ni];
                dat[i] = dat[ni];
                i = ni;
            }
            heap[i] = key;
            dat[i] = val;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<long, int> Pop()
        {
            var ret = new KeyValuePair<long, int>(heap[0], dat[0]);
            var key = heap[--Count];
            var val = dat[Count];
            if (Count == 0) return ret;
            var i = 0; while ((i << 1) + 1 < Count)
            {
                var i1 = (i << 1) + 1;
                var i2 = (i << 1) + 2;
                if (i2 < Count && heap[i1] > heap[i2]) i1 = i2;
                if (key <= heap[i1]) break;
                heap[i] = heap[i1];
                dat[i] = dat[i1];
                i = i1;
            }
            heap[i] = key;
            dat[i] = val;
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Expand()
        {
            var tmp = new long[Count << 1];
            for (var i = 0; i < heap.Length; ++i) tmp[i] = heap[i];
            heap = tmp;
            var tmp2 = new int[Count << 1];
            for (var i = 0; i < dat.Length; ++i) tmp2[i] = dat[i];
            dat = tmp2;
        }
    }
    class LIB_PriorityQueue<T>
    {
        T[] heap;
        Comparison<T> comp;
        public T Peek => heap[0];
        public long Count
        {
            get;
            private set;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, Comparison<T> cmp, bool asc = true)
        {
            heap = new T[cap];
            comp = asc ? cmp : (x, y) => cmp(y, x);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(Comparison<T> cmp, bool asc = true)
        {
            heap = new T[128];
            comp = asc ? cmp : (x, y) => cmp(y, x);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, bool asc = true) : this(cap, Comparer<T>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(bool asc = true) : this(Comparer<T>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(T val)
        {
            if (Count == heap.Length) Expand();
            var i = Count++;
            heap[i] = val;
            while (i > 0)
            {
                var ni = (i - 1) / 2;
                if (comp(val, heap[ni]) >= 0) break;
                heap[i] = heap[ni];
                i = ni;
            }
            heap[i] = val;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Pop()
        {
            var ret = heap[0];
            var val = heap[--Count];
            if (Count == 0) return ret;
            var i = 0; while ((i << 1) + 1 < Count)
            {
                var i1 = (i << 1) + 1;
                var i2 = (i << 1) + 2;
                if (i2 < Count && comp(heap[i1], heap[i2]) > 0) i1 = i2;
                if (comp(val, heap[i1]) <= 0) break;
                heap[i] = heap[i1]; i = i1;
            }
            heap[i] = val;
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Expand()
        {
            var tmp = new T[Count << 1];
            for (var i = 0; i < heap.Length; ++i) tmp[i] = heap[i];
            heap = tmp;
        }
    }
    class LIB_PriorityQueue<TK, TV>
    {
        LIB_PriorityQueue<KeyValuePair<TK, TV>> q;
        public KeyValuePair<TK, TV> Peek => q.Peek;
        public long Count => q.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, Comparison<TK> cmp, bool asc = true)
        {
            q = new LIB_PriorityQueue<KeyValuePair<TK, TV>>(cap, (x, y) => cmp(x.Key, y.Key), asc);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(Comparison<TK> cmp, bool asc = true)
        {
            q = new LIB_PriorityQueue<KeyValuePair<TK, TV>>((x, y) => cmp(x.Key, y.Key), asc);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(long cap, bool asc = true) : this(cap, Comparer<TK>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_PriorityQueue(bool asc = true) : this(Comparer<TK>.Default.Compare, asc) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Push(TK k, TV v) => q.Push(new KeyValuePair<TK, TV>(k, v));
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<TK, TV> Pop() => q.Pop();
    }
    class LIB_FastIO
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIO() { str = Console.OpenStandardInput(); }
        readonly Stream str;
        readonly byte[] buf = new byte[2048];
        int len, ptr;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        byte read()
        {
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 2048)) <= 0)
                {
                    return 0;
                }
            }
            return buf[ptr++];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = (ret << 3) + (ret << 1) + b - '0';
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
    class LIB_FastIODebug : LIB_FastIO
    {
        Queue<string> param = new Queue<string>();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIODebug() { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string Scan() => NextString();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override long Long() => long.Parse(NextString());
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override double Double() => double.Parse(NextString());
    }
    class LIB_UnionFind<T>
    {
        int[] d;
        T[] v;
        Func<T, T, T> f;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(IEnumerable<T> s, Func<T, T, T> func)
        {
            v = s.ToArray();
            d = Enumerable.Repeat(-1, v.Length).ToArray();
            f = func;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Unite(long x, long y)
        {
            x = Root(x);
            y = Root(y);
            if (x != y)
            {
                d[x] = d[x] + d[y];
                v[x] = f(v[x], v[y]);
                d[y] = (int)x;
            }
            return x != y;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool IsSame(long x, long y) => Root(x) == Root(y);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Root(long x) => d[x] < 0 ? x : d[x] = (int)Root(d[x]);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Count(long x) => -d[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Calc(long x) => v[Root(x)];
    }
    class LIB_UnionFind : LIB_UnionFind<int>
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(long n) : base(Enumerable.Repeat(0, (int)n), (x, y) => x + y) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        new private void Calc(long x) { }
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ProblemD
    {
        static bool SAIKI = false;
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var n = (int)NN;
            var m = (int)NN;
            var q = (int)NN;
            var pList = NNList(n);
            var ab = Repeat(0, m).Select(_ => new { a = (int)NN - 1, b = (int)NN - 1 }).ToArray();
            var query = Repeat(0, q).Select(_ => new { t = (int)NN, param = (int)NN }).ToArray();
            var uf = new LIB_UnionFind<LIB_RedBlackTree<long>>(Range(0, n).Select(e =>
            {
                var ret = new LIB_RedBlackTree<long>();
                ret.Add(pList[e]);
                return ret;
            }), (x, y) =>
            {
                var rt = LIB_UnionFind.RootVtx.Y;
                if (x.Count < y.Count) { var t = x; x = y; y = t; rt = LIB_UnionFind.RootVtx.X; }
                foreach (var item in x.List()) y.Add(item);
                return (rt, y);
            }, (x, y) =>
            {
                foreach (var item in x.List().ToArray())
                {
                    if (y.ContainsKey(item)) y.Remove(item);
                    else x.Remove(item);
                }
                return (x, y);
            });
            var deleted = new bool[m];
            foreach (var item in query)
            {
                if (item.t == 2) deleted[item.param - 1] = true;
            }
            for (var i = 0; i < m; i++)
            {
                if (!deleted[i]) uf.Unite(ab[i].a, ab[i].b);
            }
            foreach (var item in query.Reverse())
            {
                if (item.t == 2) uf.Unite(ab[item.param - 1].a, ab[item.param - 1].b);
            }
            foreach (var item in query)
            {
                if (item.t == 1)
                {
                    var set = uf.Calc(item.param - 1);
                    var value = 0L;
                    if (set.Count > 0)
                    {
                        value = set.Max();
                        set.Remove(value);
                    }
                    Console.WriteLine(value);
                }
                else uf.Undo();
            }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static LIB_FastIO fastio = new LIB_FastIODebug();
        static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }
        static long NN => fastio.Long();
        static double ND => fastio.Double();
        static string NS => fastio.Scan();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);
        static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);
        static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
        static bool Chmax<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }
        static bool Chmin<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }
    }
}
namespace Library {
    class LIB_UnionFind<T>
    {
        int[] d;
        Stack<(int, int)> h;
        T[] v;
        Func<T, T, (LIB_UnionFind.RootVtx, T)> f;
        Func<T, T, (T, T)> rf;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(IEnumerable<T> s, Func<T, T, (LIB_UnionFind.RootVtx, T)> func, Func<T, T, (T, T)> revFunc)
        {
            v = s.ToArray();
            d = Enumerable.Repeat(-1, v.Length).ToArray();
            f = func;
            rf = revFunc;
            h = new Stack<(int, int)>();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Unite(long x, long y)
        {
            x = Root(x);
            y = Root(y);
            if (x != y)
            {
                var (root, value) = f(v[x], v[y]);
                if (root == LIB_UnionFind.RootVtx.X)
                {
                    h.Push(((int)y, d[y]));
                    h.Push(((int)x, d[x]));
                    d[x] = d[x] + d[y];
                    d[y] = (int)x;
                    v[x] = value;
                }
                else
                {
                    h.Push(((int)x, d[x]));
                    h.Push(((int)y, d[y]));
                    d[y] = d[x] + d[y];
                    d[x] = (int)y;
                    v[y] = value;
                }
            }
            else
            {
                h.Push(((int)y, d[y]));
                h.Push(((int)x, d[x]));
            }
            return x != y;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Undo()
        {
            var pop1 = h.Pop();
            var pop2 = h.Pop();
            if (pop1.Item1 == pop2.Item1) return;
            d[pop1.Item1] = pop1.Item2;
            d[pop2.Item1] = pop2.Item2;
            (v[pop1.Item1], v[pop2.Item1]) = rf(v[pop1.Item1], v[pop2.Item1]);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool IsSame(long x, long y) => Root(x) == Root(y);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Root(long x) => d[x] < 0 ? x : d[x] = (int)Root(d[x]);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Count(long x) => -d[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Calc(long x) => v[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Snapshot() => h.Clear();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Rollback()
        {
            while (h.Count > 0) Undo();
        }
    }
    class LIB_UnionFind : LIB_UnionFind<int>
    {
        public enum RootVtx { X, Y };
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(long n) : base(Enumerable.Repeat(0, (int)n), (x, y) => (RootVtx.X, x + y), (x, y) =>
        {
            if (x < y) return (x, y - x);
            else return (x - y, y);
        })
        { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        new private void Calc(long x) { }
    }
    class LIB_FastIO
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIO() { str = Console.OpenStandardInput(); }
        readonly Stream str;
        readonly byte[] buf = new byte[2048];
        int len, ptr;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        byte read()
        {
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 2048)) <= 0)
                {
                    return 0;
                }
            }
            return buf[ptr++];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = (ret << 3) + (ret << 1) + b - '0';
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
    class LIB_FastIODebug : LIB_FastIO
    {
        Queue<string> param = new Queue<string>();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIODebug() { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string Scan() => NextString();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override long Long() => long.Parse(NextString());
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override double Double() => double.Parse(NextString());
    }
    class LIB_RedBlackTree
    {
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeMin() => new LIB_RedBlackTree<long, long, long>(long.MaxValue, long.MinValue + 100, Math.Min, (x, y, c) => y, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeMin() => new LIB_RedBlackTree<long, long, long>(long.MaxValue, 0, Math.Min, (x, y, c) => x + y, (x, y) => x + y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeMax() => new LIB_RedBlackTree<long, long, long>(long.MinValue, long.MaxValue - 100, Math.Max, (x, y, c) => y, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeMax() => new LIB_RedBlackTree<long, long, long>(long.MinValue, 0, Math.Max, (x, y, c) => x + y, (x, y) => x + y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeSum() => new LIB_RedBlackTree<long, long, long>(0, long.MaxValue, (x, y) => x + y, (x, y, c) => y * c, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeSum() => new LIB_RedBlackTree<long, long, long>(0, 0, (x, y) => x + y, (x, y, c) => x + y * c, (x, y) => x + y);
    }
    class LIB_RedBlackTree<Key, ValueT, ValueE> where ValueE : IEquatable<ValueE>
    {
        bool ope;
        class Node
        {
            public Node left;
            public Node right;
            public Key key;
            public ValueT val;
            public ValueT dat;
            public ValueE lazy;
            public bool isBlack;
            public int cnt;
            public bool needRecalc;
        }
        Func<ValueT, ValueT, ValueT> f;
        Func<ValueT, ValueE, int, ValueT> g;
        Func<ValueE, ValueE, ValueE> h;
        ValueT ti;
        ValueE ei;
        Comparison<Key> c;
        Node root;
        bool isNeedFix;
        Node lmax;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(ValueT ti, ValueE ei, Func<ValueT, ValueT, ValueT> f, Func<ValueT, ValueE, int, ValueT> g, Func<ValueE, ValueE, ValueE> h, Comparison<Key> c, bool ope = true)
        {
            this.ti = ti;
            this.ei = ei;
            this.f = f;
            this.g = g;
            this.h = h;
            this.c = c;
            this.ope = ope;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(ValueT ti, ValueE ei, Func<ValueT, ValueT, ValueT> f, Func<ValueT, ValueE, int, ValueT> g, Func<ValueE, ValueE, ValueE> h) : this(ti, ei, f, g, h, Comparer<Key>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        bool IsRed(Node n) => n != null && !n.isBlack;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        bool IsBlack(Node n) => n != null && n.isBlack;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        int Cnt(Node n) => n == null ? 0 : n.cnt;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Eval(Node n)
        {
            if (n == null || ei.Equals(n.lazy)) return;
            n.val = g(n.val, n.lazy, 1);
            if (!n.needRecalc) n.dat = g(n.dat, n.lazy, Cnt(n));
            if (n.left != null) n.left.lazy = h(n.left.lazy, n.lazy);
            if (n.right != null) n.right.lazy = h(n.right.lazy, n.lazy);
            n.lazy = ei;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Recalc(Node n)
        {
            if (n == null) return;
            Eval(n);
            if (!n.needRecalc) return;
            n.needRecalc = false;
            n.dat = n.val;
            if (n.left != null)
            {
                Recalc(n.left);
                n.dat = f(n.left.dat, n.dat);
            }
            if (n.right != null)
            {
                Recalc(n.right);
                n.dat = f(n.dat, n.right.dat);
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateL(Node n)
        {
            if (ope) { Eval(n); Eval(n.right); }
            Node m = n.right, t = m.left;
            m.left = n; n.right = t;
            n.cnt -= m.cnt - Cnt(t);
            m.cnt += n.cnt - Cnt(t);
            n.needRecalc = true; m.needRecalc = true;
            return m;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateR(Node n)
        {
            if (ope) { Eval(n); Eval(n.left); }
            Node m = n.left, t = m.right;
            m.right = n; n.left = t;
            n.cnt -= m.cnt - Cnt(t);
            m.cnt += n.cnt - Cnt(t);
            n.needRecalc = true; m.needRecalc = true;
            return m;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateLR(Node n)
        {
            n.left = RotateL(n.left);
            return RotateR(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateRL(Node n)
        {
            n.right = RotateR(n.right);
            return RotateL(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(Key key, ValueT val)
        {
            root = Add(root, key, val);
            root.isBlack = true;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Add(Node n, Key key, ValueT val)
        {
            if (n == null)
            {
                isNeedFix = true;
                return new Node() { key = key, val = val, dat = val, lazy = ei, cnt = 1 };
            }
            if (ope) Eval(n);
            if (c(key, n.key) < 0) n.left = Add(n.left, key, val);
            else n.right = Add(n.right, key, val);
            n.needRecalc = true;
            ++n.cnt;
            return Balance(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Balance(Node n)
        {
            if (!isNeedFix || !IsBlack(n)) return n;
            if (IsRed(n.left) && IsRed(n.left.left))
            {
                n = RotateR(n);
                n.left.isBlack = true;
            }
            else if (IsRed(n.left) && IsRed(n.left.right))
            {
                n = RotateLR(n);
                n.left.isBlack = true;
            }
            else if (IsRed(n.right) && IsRed(n.right.left))
            {
                n = RotateRL(n);
                n.right.isBlack = true;
            }
            else if (IsRed(n.right) && IsRed(n.right.right))
            {
                n = RotateL(n);
                n.right.isBlack = true;
            }
            else isNeedFix = false;
            return n;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(Key key)
        {
            root = Remove(root, key);
            if (root != null) root.isBlack = true;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Remove(Node n, Key key)
        {
            if (ope) Eval(n);
            --n.cnt;
            var r = c(key, n.key);
            if (r < 0)
            {
                n.left = Remove(n.left, key);
                n.needRecalc = true;
                return BalanceL(n);
            }
            if (r > 0)
            {
                n.right = Remove(n.right, key);
                n.needRecalc = true;
                return BalanceR(n);
            }
            if (n.left == null)
            {
                isNeedFix = n.isBlack;
                return n.right;
            }
            n.left = RemoveMax(n.left);
            n.key = lmax.key;
            n.val = lmax.val;
            n.needRecalc = true;
            return BalanceL(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RemoveMax(Node n)
        {
            if (ope) Eval(n);
            --n.cnt;
            if (n.right != null)
            {
                n.right = RemoveMax(n.right);
                n.needRecalc = true;
                return BalanceR(n);
            }
            lmax = n;
            isNeedFix = n.isBlack;
            return n.left;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node BalanceL(Node n)
        {
            if (!isNeedFix) return n;
            if (IsBlack(n.right) && IsRed(n.right.left))
            {
                var b = n.isBlack;
                n = RotateRL(n);
                n.isBlack = b;
                n.left.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.right) && IsRed(n.right.right))
            {
                var b = n.isBlack;
                n = RotateL(n);
                n.isBlack = b;
                n.right.isBlack = true;
                n.left.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.right))
            {
                isNeedFix = n.isBlack;
                n.isBlack = true;
                n.right.isBlack = false;
            }
            else
            {
                n = RotateL(n);
                n.isBlack = true;
                n.left.isBlack = false;
                n.left = BalanceL(n.left);
                isNeedFix = false;
            }
            return n;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node BalanceR(Node n)
        {
            if (!isNeedFix) return n;
            if (IsBlack(n.left) && IsRed(n.left.right))
            {
                var b = n.isBlack;
                n = RotateLR(n);
                n.isBlack = b; n.right.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.left) && IsRed(n.left.left))
            {
                var b = n.isBlack;
                n = RotateR(n);
                n.isBlack = b;
                n.left.isBlack = true;
                n.right.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.left))
            {
                isNeedFix = n.isBlack;
                n.isBlack = true;
                n.left.isBlack = false;
            }
            else
            {
                n = RotateR(n);
                n.isBlack = true;
                n.right.isBlack = false;
                n.right = BalanceR(n.right);
                isNeedFix = false;
            }
            return n;
        }
        public KeyValuePair<Key, ValueT> this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return At(root, i); }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        KeyValuePair<Key, ValueT> At(Node n, long i)
        {
            if (ope) Eval(n);
            if (n.left == null)
            {
                if (i == 0) return new KeyValuePair<Key, ValueT>(n.key, n.val);
                else return At(n.right, i - 1);
            }
            if (n.left.cnt == i) return new KeyValuePair<Key, ValueT>(n.key, n.val);
            if (n.left.cnt > i) return At(n.left, i);
            return At(n.right, i - n.left.cnt - 1);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(Key key)
        {
            var t = LowerBound(key);
            return t < Cnt(root) && c(At(root, t).Key, key) == 0;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(Key key) => UpperBound(root, key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        long UpperBound(Node n, Key key)
        {
            if (n == null) return 0;
            var r = c(key, n.key);
            if (r < 0) return UpperBound(n.left, key);
            return Cnt(n.left) + 1 + UpperBound(n.right, key);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(Key key) => LowerBound(root, key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        long LowerBound(Node n, Key key)
        {
            if (n == null) return 0;
            var r = c(key, n.key);
            if (r <= 0) return LowerBound(n.left, key);
            return Cnt(n.left) + 1 + LowerBound(n.right, key);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, ValueT> Min()
        {
            Node n = root.left, p = root;
            while (n != null)
            {
                p = n;
                if (ope) Eval(p);
                n = n.left;
            }
            return new KeyValuePair<Key, ValueT>(p.key, p.val);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, ValueT> Max()
        {
            Node n = root.right, p = root;
            while (n != null)
            {
                p = n;
                if (ope) Eval(p);
                n = n.right;
            }
            return new KeyValuePair<Key, ValueT>(p.key, p.val);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Update(long l, long r, ValueE val) => Update(root, l, r, val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Update(Node n, long l, long r, ValueE val)
        {
            if (n == null) return;
            Eval(n);
            n.needRecalc = true;
            var lc = Cnt(n.left);
            if (lc < l) Update(n.right, l - lc - 1, r - lc - 1, val);
            else if (r <= lc) Update(n.left, l, r, val);
            else if (l <= 0 && Cnt(n) <= r) n.lazy = val;
            else
            {
                n.val = g(n.val, val, 1);
                if (l < lc) Update(n.left, l, lc, val);
                if (lc + 1 < r) Update(n.right, 0, r - lc - 1, val);
            }
            return;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public ValueT Query(long l, long r) => Query(root, l, r);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        ValueT Query(Node n, long l, long r)
        {
            var v1 = ti; var v2 = ti; var v3 = ti;
            if (n == null) return ti;
            Eval(n);
            var lc = Cnt(n.left);
            if (lc < l) v3 = Query(n.right, l - lc - 1, r - lc - 1);
            else if (r <= lc) v1 = Query(n.left, l, r);
            else if (l <= 0 && Cnt(n) <= r)
            {
                Recalc(n);
                v2 = n.dat;
            }
            else
            {
                if (l < lc) v1 = Query(n.left, l, lc);
                if (lc + 1 < r) v3 = Query(n.right, 0, r - lc - 1);
                v2 = n.val;
            }
            return f(f(v1, v2), v3);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => root != null;
        public long Count => Cnt(root);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<KeyValuePair<Key, ValueT>> List() => L(root);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        IEnumerable<KeyValuePair<Key, ValueT>> L(Node n)
        {
            if (n == null) yield break;
            foreach (var i in L(n.left)) yield return i;
            yield return new KeyValuePair<Key, ValueT>(n.key, n.val);
            foreach (var i in L(n.right)) yield return i;
        }
    }
    class LIB_RedBlackTree<Key, Value>
    {
        LIB_RedBlackTree<Key, Value, int> tree;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(Comparison<Key> c) { tree = new LIB_RedBlackTree<Key, Value, int>(default(Value), 0, null, null, null, c, false); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree() : this(Comparer<Key>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(Key key, Value val) => tree.Add(key, val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(Key key) => tree.Remove(key);
        public KeyValuePair<Key, Value> this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return tree[i]; }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(Key key) => tree.ContainsKey(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(Key key) => tree.UpperBound(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(Key key) => tree.LowerBound(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, Value> Min() => tree.Min();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, Value> Max() => tree.Max();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => tree.Any();
        public long Count => tree.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<KeyValuePair<Key, Value>> List() => tree.List();
    }
    class LIB_RedBlackTree<T>
    {
        LIB_RedBlackTree<T, int, int> tree;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(Comparison<T> c) { tree = new LIB_RedBlackTree<T, int, int>(0, 0, null, null, null, c, false); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree() : this(Comparer<T>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(T val) => tree.Add(val, 0);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(T val) => tree.Remove(val);
        public T this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return tree[i].Key; }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(T val) => tree.ContainsKey(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(T val) => tree.UpperBound(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(T val) => tree.LowerBound(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Min() => tree.Min().Key;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Max() => tree.Max().Key;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => tree.Any();
        public long Count => tree.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<T> List() => tree.List().Select(e => e.Key);
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    static List<List<int>> g;

    class Dsu
    {
        public readonly List<int> parent;

        public Dsu(int n)
        {
            parent = Enumerable.Range(0, n).ToList();
            g = Init<List<int>>(n).ToList();
        }

        public int FindSet(int v)
        {
            if (v == parent[v])
                return v;
            return parent[v] = FindSet(parent[v]);
        }

        public void UnionSets(int a, int b)
        {
            a = FindSet(a);
            b = FindSet(b);
            if (a != b)
            {
                parent[a] = parent[b] = parent.Count;
                g.Add(new List<int>());
                g[parent.Count].Add(a);
                g[parent.Count].Add(b);
                parent.Add(parent.Count);
            }
        }
    }

    int[] c;
    int[] tree;

    int Cmp(int l, int r)
    {
        return c2[l] > c2[r] ? l : r;
    }

    void Build(int x, int xl, int xr)
    {
        if (xl == xr)
        {
            tree[x] = xl;
            return;
        }
        int xm = (xl + xr) / 2;
        Build(x * 2, xl, xm);
        Build(x * 2 + 1, xm + 1, xr);
        tree[x] = Cmp(tree[2 * x], tree[2 * x + 1]);
    }

    void Set(int x, int xl, int xr, int idx)
    {
        if (xl == xr)
        {
            c2[xl] = 0;
            return;
        }

        int xm = (xl + xr) / 2;
        if (idx <= xm)
            Set(x * 2, xl, xm, idx);
        else
            Set(x * 2 + 1, xm + 1, xr, idx);
        tree[x] = Cmp(tree[2 * x], tree[2 * x + 1]);
    }

    int Query(int x, int xl, int xr, int l, int r)
    {
        if (l == xl && r == xr)
            return tree[x];
        int xm = (xl + xr) / 2;
        if (r <= xm)
            return Query(x * 2, xl, xm, l, r);
        if (l > xm)
            return Query(x * 2 + 1, xm + 1, xr, l, r);
        return Cmp(Query(x * 2, xl, xm, l, xm), Query(x * 2 + 1, xm + 1, xr, xm + 1, r));
    }

    int n;
    bool[] vis;
    int[] tin, tout, c2;
    int timer;
    void Dfs(int x)
    {
        if (x < n)
            c2[timer] = c[x];
        vis[x] = true;
        tin[x] = timer++;
        foreach (int e in g[x])
            Dfs(e);
        tout[x] = timer;
    }

    public void Solve()
    {
        n = ReadInt();
        int m = ReadInt();
        int q = ReadInt();
        c = ReadIntArray();
        var a = ReadIntMatrix(m);
        var b = ReadIntMatrix(q);

        n = 200000;
        m = 199999;
        q = 500000;
        c = new int[n];
        var rnd = new Random(13);
        for (int i = 0; i < n; i++)
            c[i] = rnd.Next(n) + 1;
        a = new int[m][];
        for (int i = 0; i < m; i++)
            a[i] = new[] { i + 1, i + 2 };
        b = new int[q][];
        int cnt = 1;
        for (int i = 0; i < q; i++)
        {
            b[i] = new int[2];
            b[i][0] = rnd.Next(2) + 1;
            if (cnt > m)
                b[i][0] = 1;
            if (b[i][0] == 1)
            {
                b[i][1] = rnd.Next(n) + 1;
            }
            else
            {
                b[i][1] = cnt++;
            }
        }

        var f = new bool[m];
        for (int i = 0; i < q; i++)
        {
            b[i][1]--;
            if (b[i][0] == 2)
                f[b[i][1]] = true;
        }

        var dsu = new Dsu(n);
        for (int i = 0; i < m; i++)
        {
            a[i][0]--;
            a[i][1]--;
            if (!f[i])
                dsu.UnionSets(a[i][0], a[i][1]);
        }

        for (int i = q - 1; i >= 0; i--)
        {
            if (b[i][0] == 1)
            {
                b[i][1] = dsu.FindSet(b[i][1]);
            }
            else
            {
                dsu.UnionSets(a[b[i][1]][0], a[b[i][1]][1]);
            }
        }

        int n2 = dsu.parent.Count;
        tin = new int[n2];
        tout = new int[n2];
        vis = new bool[n2];
        c2 = new int[n2];
        for (int i = n2 - 1; i >= 0; i--)
            if (!vis[i])
                Dfs(i);

        tree = new int[4 * n2];
        Build(1, 0, n2 - 1);
        for (int i = 0; i < q; i++)
            if (b[i][0] == 1)
            {
                int x = Query(1, 0, n2 - 1, tin[b[i][1]], tout[b[i][1]] - 1);
                Write(c2[x]);
                Set(1, 0, n2 - 1, x);
            }
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("input.txt");
        //writer = new StreamWriter("output.txt");
#endif
        try
        {
            //new Solver().Solve();
            var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            thread.Start();
            thread.Join();
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0) currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i]; }
        return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++) lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array) writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++) ret[i] = new T(); return ret; }
    #endregion
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ProblemD
    {
        static bool SAIKI = false;
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var n = (int)NN;
            var m = (int)NN;
            var q = (int)NN;
            var pList = NNList(n);
            var ab = Repeat(0, m).Select(_ => new { a = (int)NN - 1, b = (int)NN - 1 }).ToArray();
            var query = Repeat(0, q).Select(_ => new { t = (int)NN, param = (int)NN }).ToArray();
            var uf = new LIB_UnionFind<LIB_RedBlackTree<long>>(Range(0, n).Select(e =>
            {
                var ret = new LIB_RedBlackTree<long>();
                ret.Add(pList[e]);
                return ret;
            }), (x, y) =>
            {
                var rt = LIB_UnionFind.RootVtx.Y;
                if (x.Count > y.Count) { var t = x; x = y; y = t; rt = LIB_UnionFind.RootVtx.X; }
                foreach (var item in x.List()) y.Add(item);
                return (rt, y);
            }, (x, y) =>
            {
                var rev = false;
                if (x.Count > y.Count)
                {
                    var t = x; x = y; y = t;
                    rev = true;
                }
                foreach (var item in x.List().ToArray())
                {
                    if (y.ContainsKey(item)) y.Remove(item);
                    else x.Remove(item);
                }
                if (rev) return (y, x);
                else return (x, y);
            });
            var deleted = new bool[m];
            foreach (var item in query)
            {
                if (item.t == 2) deleted[item.param - 1] = true;
            }
            for (var i = 0; i < m; i++)
            {
                if (!deleted[i]) uf.Unite(ab[i].a, ab[i].b);
            }
            foreach (var item in query.Reverse())
            {
                if (item.t == 2) uf.Unite(ab[item.param - 1].a, ab[item.param - 1].b);
            }
            foreach (var item in query)
            {
                if (item.t == 1)
                {
                    var set = uf.Calc(item.param - 1);
                    var value = 0L;
                    if (set.Count > 0)
                    {
                        value = set.Max();
                        set.Remove(value);
                    }
                    Console.WriteLine(value);
                }
                else uf.Undo();
            }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static LIB_FastIO fastio = new LIB_FastIODebug();
        static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }
        static long NN => fastio.Long();
        static double ND => fastio.Double();
        static string NS => fastio.Scan();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);
        static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);
        static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
        static bool Chmax<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }
        static bool Chmin<T>(this ref T lhs, T rhs) where T : struct, IComparable<T> { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }
    }
}
namespace Library {
    class LIB_RedBlackTree
    {
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeMin() => new LIB_RedBlackTree<long, long, long>(long.MaxValue, long.MinValue + 100, Math.Min, (x, y, c) => y, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeMin() => new LIB_RedBlackTree<long, long, long>(long.MaxValue, 0, Math.Min, (x, y, c) => x + y, (x, y) => x + y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeMax() => new LIB_RedBlackTree<long, long, long>(long.MinValue, long.MaxValue - 100, Math.Max, (x, y, c) => y, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeMax() => new LIB_RedBlackTree<long, long, long>(long.MinValue, 0, Math.Max, (x, y, c) => x + y, (x, y) => x + y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeUpdateRangeSum() => new LIB_RedBlackTree<long, long, long>(0, long.MaxValue, (x, y) => x + y, (x, y, c) => y * c, (x, y) => y);
        static public LIB_RedBlackTree<long, long, long> CreateRangeAddRangeSum() => new LIB_RedBlackTree<long, long, long>(0, 0, (x, y) => x + y, (x, y, c) => x + y * c, (x, y) => x + y);
    }
    class LIB_RedBlackTree<Key, ValueT, ValueE> where ValueE : IEquatable<ValueE>
    {
        bool ope;
        class Node
        {
            public Node left;
            public Node right;
            public Key key;
            public ValueT val;
            public ValueT dat;
            public ValueE lazy;
            public bool isBlack;
            public int cnt;
            public bool needRecalc;
        }
        Func<ValueT, ValueT, ValueT> f;
        Func<ValueT, ValueE, int, ValueT> g;
        Func<ValueE, ValueE, ValueE> h;
        ValueT ti;
        ValueE ei;
        Comparison<Key> c;
        Node root;
        bool isNeedFix;
        Node lmax;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(ValueT ti, ValueE ei, Func<ValueT, ValueT, ValueT> f, Func<ValueT, ValueE, int, ValueT> g, Func<ValueE, ValueE, ValueE> h, Comparison<Key> c, bool ope = true)
        {
            this.ti = ti;
            this.ei = ei;
            this.f = f;
            this.g = g;
            this.h = h;
            this.c = c;
            this.ope = ope;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(ValueT ti, ValueE ei, Func<ValueT, ValueT, ValueT> f, Func<ValueT, ValueE, int, ValueT> g, Func<ValueE, ValueE, ValueE> h) : this(ti, ei, f, g, h, Comparer<Key>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        bool IsRed(Node n) => n != null && !n.isBlack;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        bool IsBlack(Node n) => n != null && n.isBlack;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        int Cnt(Node n) => n == null ? 0 : n.cnt;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Eval(Node n)
        {
            if (n == null || ei.Equals(n.lazy)) return;
            n.val = g(n.val, n.lazy, 1);
            if (!n.needRecalc) n.dat = g(n.dat, n.lazy, Cnt(n));
            if (n.left != null) n.left.lazy = h(n.left.lazy, n.lazy);
            if (n.right != null) n.right.lazy = h(n.right.lazy, n.lazy);
            n.lazy = ei;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Recalc(Node n)
        {
            if (n == null) return;
            Eval(n);
            if (!n.needRecalc) return;
            n.needRecalc = false;
            n.dat = n.val;
            if (n.left != null)
            {
                Recalc(n.left);
                n.dat = f(n.left.dat, n.dat);
            }
            if (n.right != null)
            {
                Recalc(n.right);
                n.dat = f(n.dat, n.right.dat);
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateL(Node n)
        {
            if (ope) { Eval(n); Eval(n.right); }
            Node m = n.right, t = m.left;
            m.left = n; n.right = t;
            n.cnt -= m.cnt - Cnt(t);
            m.cnt += n.cnt - Cnt(t);
            n.needRecalc = true; m.needRecalc = true;
            return m;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateR(Node n)
        {
            if (ope) { Eval(n); Eval(n.left); }
            Node m = n.left, t = m.right;
            m.right = n; n.left = t;
            n.cnt -= m.cnt - Cnt(t);
            m.cnt += n.cnt - Cnt(t);
            n.needRecalc = true; m.needRecalc = true;
            return m;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateLR(Node n)
        {
            n.left = RotateL(n.left);
            return RotateR(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RotateRL(Node n)
        {
            n.right = RotateR(n.right);
            return RotateL(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(Key key, ValueT val)
        {
            root = Add(root, key, val);
            root.isBlack = true;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Add(Node n, Key key, ValueT val)
        {
            if (n == null)
            {
                isNeedFix = true;
                return new Node() { key = key, val = val, dat = val, lazy = ei, cnt = 1 };
            }
            if (ope) Eval(n);
            if (c(key, n.key) < 0) n.left = Add(n.left, key, val);
            else n.right = Add(n.right, key, val);
            n.needRecalc = true;
            ++n.cnt;
            return Balance(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Balance(Node n)
        {
            if (!isNeedFix || !IsBlack(n)) return n;
            if (IsRed(n.left) && IsRed(n.left.left))
            {
                n = RotateR(n);
                n.left.isBlack = true;
            }
            else if (IsRed(n.left) && IsRed(n.left.right))
            {
                n = RotateLR(n);
                n.left.isBlack = true;
            }
            else if (IsRed(n.right) && IsRed(n.right.left))
            {
                n = RotateRL(n);
                n.right.isBlack = true;
            }
            else if (IsRed(n.right) && IsRed(n.right.right))
            {
                n = RotateL(n);
                n.right.isBlack = true;
            }
            else isNeedFix = false;
            return n;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(Key key)
        {
            root = Remove(root, key);
            if (root != null) root.isBlack = true;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node Remove(Node n, Key key)
        {
            if (ope) Eval(n);
            --n.cnt;
            var r = c(key, n.key);
            if (r < 0)
            {
                n.left = Remove(n.left, key);
                n.needRecalc = true;
                return BalanceL(n);
            }
            if (r > 0)
            {
                n.right = Remove(n.right, key);
                n.needRecalc = true;
                return BalanceR(n);
            }
            if (n.left == null)
            {
                isNeedFix = n.isBlack;
                return n.right;
            }
            n.left = RemoveMax(n.left);
            n.key = lmax.key;
            n.val = lmax.val;
            n.needRecalc = true;
            return BalanceL(n);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node RemoveMax(Node n)
        {
            if (ope) Eval(n);
            --n.cnt;
            if (n.right != null)
            {
                n.right = RemoveMax(n.right);
                n.needRecalc = true;
                return BalanceR(n);
            }
            lmax = n;
            isNeedFix = n.isBlack;
            return n.left;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node BalanceL(Node n)
        {
            if (!isNeedFix) return n;
            if (IsBlack(n.right) && IsRed(n.right.left))
            {
                var b = n.isBlack;
                n = RotateRL(n);
                n.isBlack = b;
                n.left.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.right) && IsRed(n.right.right))
            {
                var b = n.isBlack;
                n = RotateL(n);
                n.isBlack = b;
                n.right.isBlack = true;
                n.left.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.right))
            {
                isNeedFix = n.isBlack;
                n.isBlack = true;
                n.right.isBlack = false;
            }
            else
            {
                n = RotateL(n);
                n.isBlack = true;
                n.left.isBlack = false;
                n.left = BalanceL(n.left);
                isNeedFix = false;
            }
            return n;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        Node BalanceR(Node n)
        {
            if (!isNeedFix) return n;
            if (IsBlack(n.left) && IsRed(n.left.right))
            {
                var b = n.isBlack;
                n = RotateLR(n);
                n.isBlack = b; n.right.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.left) && IsRed(n.left.left))
            {
                var b = n.isBlack;
                n = RotateR(n);
                n.isBlack = b;
                n.left.isBlack = true;
                n.right.isBlack = true;
                isNeedFix = false;
            }
            else if (IsBlack(n.left))
            {
                isNeedFix = n.isBlack;
                n.isBlack = true;
                n.left.isBlack = false;
            }
            else
            {
                n = RotateR(n);
                n.isBlack = true;
                n.right.isBlack = false;
                n.right = BalanceR(n.right);
                isNeedFix = false;
            }
            return n;
        }
        public KeyValuePair<Key, ValueT> this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return At(root, i); }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        KeyValuePair<Key, ValueT> At(Node n, long i)
        {
            if (ope) Eval(n);
            if (n.left == null)
            {
                if (i == 0) return new KeyValuePair<Key, ValueT>(n.key, n.val);
                else return At(n.right, i - 1);
            }
            if (n.left.cnt == i) return new KeyValuePair<Key, ValueT>(n.key, n.val);
            if (n.left.cnt > i) return At(n.left, i);
            return At(n.right, i - n.left.cnt - 1);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(Key key)
        {
            var t = LowerBound(key);
            return t < Cnt(root) && c(At(root, t).Key, key) == 0;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(Key key) => UpperBound(root, key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        long UpperBound(Node n, Key key)
        {
            if (n == null) return 0;
            var r = c(key, n.key);
            if (r < 0) return UpperBound(n.left, key);
            return Cnt(n.left) + 1 + UpperBound(n.right, key);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(Key key) => LowerBound(root, key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        long LowerBound(Node n, Key key)
        {
            if (n == null) return 0;
            var r = c(key, n.key);
            if (r <= 0) return LowerBound(n.left, key);
            return Cnt(n.left) + 1 + LowerBound(n.right, key);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, ValueT> Min()
        {
            Node n = root.left, p = root;
            while (n != null)
            {
                p = n;
                if (ope) Eval(p);
                n = n.left;
            }
            return new KeyValuePair<Key, ValueT>(p.key, p.val);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, ValueT> Max()
        {
            Node n = root.right, p = root;
            while (n != null)
            {
                p = n;
                if (ope) Eval(p);
                n = n.right;
            }
            return new KeyValuePair<Key, ValueT>(p.key, p.val);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Update(long l, long r, ValueE val) => Update(root, l, r, val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        void Update(Node n, long l, long r, ValueE val)
        {
            if (n == null) return;
            Eval(n);
            n.needRecalc = true;
            var lc = Cnt(n.left);
            if (lc < l) Update(n.right, l - lc - 1, r - lc - 1, val);
            else if (r <= lc) Update(n.left, l, r, val);
            else if (l <= 0 && Cnt(n) <= r) n.lazy = val;
            else
            {
                n.val = g(n.val, val, 1);
                if (l < lc) Update(n.left, l, lc, val);
                if (lc + 1 < r) Update(n.right, 0, r - lc - 1, val);
            }
            return;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public ValueT Query(long l, long r) => Query(root, l, r);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        ValueT Query(Node n, long l, long r)
        {
            var v1 = ti; var v2 = ti; var v3 = ti;
            if (n == null) return ti;
            Eval(n);
            var lc = Cnt(n.left);
            if (lc < l) v3 = Query(n.right, l - lc - 1, r - lc - 1);
            else if (r <= lc) v1 = Query(n.left, l, r);
            else if (l <= 0 && Cnt(n) <= r)
            {
                Recalc(n);
                v2 = n.dat;
            }
            else
            {
                if (l < lc) v1 = Query(n.left, l, lc);
                if (lc + 1 < r) v3 = Query(n.right, 0, r - lc - 1);
                v2 = n.val;
            }
            return f(f(v1, v2), v3);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => root != null;
        public long Count => Cnt(root);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<KeyValuePair<Key, ValueT>> List() => L(root);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        IEnumerable<KeyValuePair<Key, ValueT>> L(Node n)
        {
            if (n == null) yield break;
            foreach (var i in L(n.left)) yield return i;
            yield return new KeyValuePair<Key, ValueT>(n.key, n.val);
            foreach (var i in L(n.right)) yield return i;
        }
    }
    class LIB_RedBlackTree<Key, Value>
    {
        LIB_RedBlackTree<Key, Value, int> tree;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(Comparison<Key> c) { tree = new LIB_RedBlackTree<Key, Value, int>(default(Value), 0, null, null, null, c, false); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree() : this(Comparer<Key>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(Key key, Value val) => tree.Add(key, val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(Key key) => tree.Remove(key);
        public KeyValuePair<Key, Value> this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return tree[i]; }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(Key key) => tree.ContainsKey(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(Key key) => tree.UpperBound(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(Key key) => tree.LowerBound(key);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, Value> Min() => tree.Min();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public KeyValuePair<Key, Value> Max() => tree.Max();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => tree.Any();
        public long Count => tree.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<KeyValuePair<Key, Value>> List() => tree.List();
    }
    class LIB_RedBlackTree<T>
    {
        LIB_RedBlackTree<T, int, int> tree;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree(Comparison<T> c) { tree = new LIB_RedBlackTree<T, int, int>(0, 0, null, null, null, c, false); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_RedBlackTree() : this(Comparer<T>.Default.Compare) { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(T val) => tree.Add(val, 0);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Remove(T val) => tree.Remove(val);
        public T this[long i]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return tree[i].Key; }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool ContainsKey(T val) => tree.ContainsKey(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long UpperBound(T val) => tree.UpperBound(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long LowerBound(T val) => tree.LowerBound(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Min() => tree.Min().Key;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Max() => tree.Max().Key;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Any() => tree.Any();
        public long Count => tree.Count;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IEnumerable<T> List() => tree.List().Select(e => e.Key);
    }
    class LIB_FastIO
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIO() { str = Console.OpenStandardInput(); }
        readonly Stream str;
        readonly byte[] buf = new byte[2048];
        int len, ptr;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        byte read()
        {
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 2048)) <= 0)
                {
                    return 0;
                }
            }
            return buf[ptr++];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = (ret << 3) + (ret << 1) + b - '0';
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
    class LIB_FastIODebug : LIB_FastIO
    {
        Queue<string> param = new Queue<string>();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIODebug() { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string Scan() => NextString();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override long Long() => long.Parse(NextString());
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override double Double() => double.Parse(NextString());
    }
    class LIB_UnionFind<T>
    {
        int[] d;
        Stack<(int, int)> h;
        Stack<T> hv;
        T[] v;
        Func<T, T, (LIB_UnionFind.RootVtx, T)> f;
        Func<T, T, (T, T)> rf;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(IEnumerable<T> s, Func<T, T, (LIB_UnionFind.RootVtx, T)> func, Func<T, T, (T, T)> revFunc)
        {
            v = s.ToArray();
            d = Enumerable.Repeat(-1, v.Length).ToArray();
            f = func;
            rf = revFunc;
            h = new Stack<(int, int)>();
            hv = new Stack<T>();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Unite(long x, long y)
        {
            x = Root(x);
            y = Root(y);
            if (x != y)
            {
                var (root, value) = f(v[x], v[y]);
                if (root == LIB_UnionFind.RootVtx.X)
                {
                    h.Push(((int)y, d[y]));
                    h.Push(((int)x, d[x]));
                    hv.Push(v[y]);
                    hv.Push(v[x]);
                    d[x] = d[x] + d[y];
                    d[y] = (int)x;
                    v[x] = value;
                }
                else
                {
                    h.Push(((int)x, d[x]));
                    h.Push(((int)y, d[y]));
                    hv.Push(v[x]);
                    hv.Push(v[y]);
                    d[y] = d[x] + d[y];
                    d[x] = (int)y;
                    v[y] = value;
                }
            }
            return x != y;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Undo()
        {
            var pop1 = h.Pop();
            var pop2 = h.Pop();
            if (pop1.Item1 == pop2.Item1) return;
            d[pop1.Item1] = pop1.Item2;
            d[pop2.Item1] = pop2.Item2;
            var popv1 = hv.Pop();
            var popv2 = hv.Pop();
            (v[pop1.Item1], v[pop2.Item1]) = rf(popv1, popv2);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool IsSame(long x, long y) => Root(x) == Root(y);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Root(long x) => d[x] < 0 ? x : d[x] = (int)Root(d[x]);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long Count(long x) => -d[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public T Calc(long x) => v[Root(x)];
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Snapshot() => h.Clear();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Rollback()
        {
            while (h.Count > 0) Undo();
        }
    }
    class LIB_UnionFind : LIB_UnionFind<int>
    {
        public enum RootVtx { X, Y };
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_UnionFind(long n) : base(Enumerable.Repeat(0, (int)n), (x, y) => (RootVtx.X, x + y), (x, y) =>
        {
            if (x < y) return (x, y - x);
            else return (x - y, y);
        })
        { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        new private void Calc(long x) { }
    }
}