Making Number

아직 제출이 없습니다시간 제한1.5초메모리 제한1024 MB

문제

You are given two positive integers XX and YY of the same length in base 10. ZZ is defined as the positive integer in base 10 satisfying the following conditions.

  • The digits of ZZ should be a rearrangement of the digits of XX. Leading zeros in ZZ are not allowed. For example, if X=1103X=1103, ZZ can be 11031103 or 31013101, but ZZ cannot be 21102110, 301301, nor 01310131.
  • YZY\leq Z.
  • ZZ is the minimum value satisfying the above conditions.

You have to perform QQ queries. Each query is one of the followings:

  • Given ii and xx, change the ii-th digit of YY to xx.
  • Given ii, output the ii-th digit of ZZ. If there is no such ZZ, print 1-1.

The ii-th digit of a positive integer is defined from the left. For example, The third digit of 12341234 is 33.

입력

The first line contains two space-separated integers, XX and YY.

The second line contains a single integer, QQ.

The following QQ lines contain space-separated integers describing the queries. Each line has one of the following forms, where the first integer represents the type of the query:

  • 1 ii xx : Change the ii-th digit of YY to xx.
  • 2 ii : Output the ii-th digit of ZZ. If there is no such ZZ, print 1-1.

It is guaranteed that there is at least one query of type 2.

출력

For each query of type 2, output the answer for the query. The answers should be separated by newlines.

제한

Let len(A)(A) be the number of digits in a positive integer AA.

  • 1X,Y<10100,0001\leq X,Y<10^{100\\, 000}
  • 1Q100,0001\leq Q\leq 100\\, 000
  • len(X)=(X) =len(Y)(Y)
  • The first digits of XX and YY are not 0.
  • For a query of type 1, 1i1\leq i\leqlen(Y)(Y), 0x90\leq x\leq 9. If i=1i=1, x0x\neq 0.
  • For a query of type 2, 1i1\leq i\leqlen(Y)(Y).