| 160 | } |
| 161 | |
| 162 | public static void main(String[] args) throws Exception { |
| 163 | FastReader in = new FastReader(System.in); |
| 164 | PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); |
| 165 | n = in.nextInt(); |
| 166 | for (int i = 1; i <= n; i++) { |
| 167 | arr[i] = in.nextInt(); |
| 168 | sum[i] = arr[i]; |
| 169 | } |
| 170 | m = in.nextInt(); |
| 171 | String op; |
| 172 | int x, y; |
| 173 | for (int i = 1; i <= m; i++) { |
| 174 | op = in.nextString(); |
| 175 | x = in.nextInt(); |
| 176 | y = in.nextInt(); |
| 177 | if (op.equals("bridge")) { |
| 178 | if (findroot(x) == findroot(y)) { |
| 179 | out.println("no"); |
| 180 | } else { |
| 181 | out.println("yes"); |
| 182 | link(x, y); |
| 183 | } |
| 184 | } else if (op.equals("penguins")) { |
| 185 | splay(x); |
| 186 | arr[x] = y; |
| 187 | up(x); |
| 188 | } else { |
| 189 | if (findroot(x) != findroot(y)) { |
| 190 | out.println("impossible"); |
| 191 | } else { |
| 192 | split(x, y); |
| 193 | out.println(sum[y]); |
| 194 | } |
| 195 | } |
| 196 | } |
| 197 | out.flush(); |
| 198 | out.close(); |
| 199 | } |
| 200 | |
| 201 | // 读写工具类 |
| 202 | static class FastReader { |