//package learning;
import java.util.*;
import java.io.*;
import java.lang.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class NitsLocal {
    static ArrayList<String> s1;
    static boolean[] prime;
    static int n = (int)1e7;

     static void sieve() {
Arrays.fill(prime	, true);
prime[0] = prime[1] = false;
for(int i = 2 ; i * i <= n ; ++i) {
if(prime[i]) {
for(int k = i * i; k<= n ; k+=i) {
prime[k] = false;
}
}
}

}
    public static void main(String[] args) {
        InputReader sc = new InputReader(System.in);

           prime  = new boolean[n + 1];
           //sieve();
                prime[1] = false;
                /*
              int n = sc.ni();
              int []a = sc.nia(n);
              int mod = 1000000007;
              long ans = 0;
              int f = 0;
              int q = sc.ni();
              while(q-- > 0)
              {
                  int num = sc.ni();
                  ans = 0;
                  if(num == 0)
                  {
                      a[sc.ni()-1] = sc.ni();
                  }
                 else
                  {
                      int l = sc.ni();
                      int r = sc.ni();
                    for(int i=l-1;i<r;i++)
                   {

                   for(int j=i+1;j<r;j++)
                   {
                      f = 0;

                      int x = a[i];
                      int y = a[j];
                      while(x > 0 && y > 0)
                      {
                          int y1 = x%10;
                          int y2 = y%10;
                          if(y1 > 0 && y2 > 0)
                          {
                              f = 1;
                          }
                          x /= 10;
                          y /= 10;
                      }

                     if(f==0)
                     {
                         ans = (ans + ((((long)a[i]%mod) * ((long)a[j]%mod)))%mod)%mod;
                     }
                  }
              }

              w.println(ans);
                  }
              }

            */
                /*
               int t  = sc.ni();
               while(t-- > 0)
               {
                   int n = sc.ni();
                   Student []st = new Student[n];
                   for(int i=0;i<n;i++)
                   {
                       st[i] = new Student(sc.ni(),sc.ni());
                   }
                   Arrays.sort(st,(p,q)->p.id-q.id);
                   if(n==1)
                       w.println("0");
                   else
                   {
                    int prev = 0;
                    int adv = 0;
                    int max = -1;
                    int min = 1000000000;
                    for(int i=0;i<n;i++)
                    {
                        min = Math.min(st[i].y,min);
                        max = Math.max(st[i].y,max);
                    }
                        if(st[0].y > st[1].y)
                        {
                            prev = st[0].id;
                        }
                        else
                            prev= st[0].y;
                         if(st[n-1].id < st[n-2].y)
                        {
                            adv = st[n-1].id;
                        }
                        else
                            prev= st[n-1].y;
                         w.println(adv-prev);

                   }
               }
             */

                       int t = 1;
                       while(t-- > 0)
                       {
                        int a = sc.ni();
                        int b = sc.ni();
                        int c = sc.ni();
                        int d = sc.ni();
                        int f = 0;
                        int g = 0;
                        if(a==b && a==0)
                        {
                            if(c==d+1 || d == c+1)
                            {
                                w.println("YES");
                                if(d > c)
                                    w.print("3 ");

                                int m = Math.min(c,d);
                                while(m-- > 0)
                                {
                                    w.print("2" + " " + "3 ");
                                }
                                if(c > d)
                                    w.print("2");
                            }
                            else if(c==d)
                            {
                                w.println("YES");
                                while(c-- > 0)
                                {
                                    w.print("2" + " " + "3  ");
                                }
                            }
                            else
                                w.println("NO");
                        }
                        else if(c == d && c == 0)
                        {
                            if(a==b+1 || b == a+1)
                            {
                                w.println("YES");
                                if(b > a)
                                    w.print("1 ");

                                int m = Math.min(a,b);
                                while(m-- > 0)
                                {
                                    w.print("0" + " " + "1 ");
                                }
                                if(a > b)
                                    w.print("0");
                            }
                            else if(a == b)
                            {
                                w.println("YES");
                                while(a-- > 0)
                                {
                                    w.print("0" + " " + "1 ");
                                }
                            }
                            else
                                w.println("NO");
                        }
                        else if(a== d && a == 0)
                        {
                            if(b==c+1 || c == b+1)
                            {
                                w.println("YES");
                                if(c > b)
                                    w.print("2 ");

                                int m = Math.min(c,b);
                                while(m-- > 0)
                                {
                                    w.print("1" + " " + "2");
                                }
                                if(c < b)
                                    w.print("1");
                            }
                            else if(b==c)
                            {
                                w.println("YES");
                                while(b-- > 0)
                                {
                                    w.print("1" + " " + "2 ");
                                }
                            }
                            else
                                w.println("NO");
                        }
                        else
                        {
                        if(a <= b)
                        {
                            int t1 = b-a;
                            if(t1 <= c)
                            {
                                if(t1 == c && d==0)
                                {
                                    if(c==0)
                                    {
                                        w.println("YES");
                                        int []res = new int[a+b+c+d+5];
                                         for(int i=0;i<a;i+=2)
                                   {
                                       res[i] = 0;
                                       res[i+1] = 1;
                                   }
                                         for(int i=0;i<a+b+c+d;i++)
                                   {
                                       w.print(res[i] + " ");
                                   }
                                    }
                                    else
                                    {
                                        w.println("YES");
                                        int []res = new int[a+b+c+d+5];
                                         for(int i=0;i<2*a;i+=2)
                                   {
                                       res[i] = 0;
                                       res[i+1] = 1;
                                   }
                                         for(int i=2*a;i<2*a +2*t1;i+=2)
                                   {
                                       res[i] = 2;
                                       res[i+1] = 1;
                                   }
                                         for(int i=0;i<a+b+c+d;i++)
                                   {
                                       w.print(res[i] + " ");
                                   }
                                    }
                                }
                                else
                                {
                                    if(t1==c && d!=0)
                                    {
                                        f = 1;
                                        t1--;
                                    }
                                int t2 = c-t1;
                                //w.println(t2);
                                if(t2 == d-1)
                                {
                                    t1--;
                                    if(t1 >= 0)
                                    {
                                    t2++;
                                    f = 1;
                                    }
                                }
                                if(t2==d || t2 ==d+1)
                                {

                                    w.println("YES");

                                   int []res = new int[a+b+c+d+5];
                                   for(int i=0;i<2*a;i+=2)
                                   {
                                       res[i] = 0;
                                       res[i+1] = 1;
                                   }
                                   for(int i=2*a;i<2*a +2*t1;i+=2)
                                   {
                                       res[i] = 2;
                                       res[i+1] = 1;
                                   }
                                   for(int i=2*a + 2*t1;i<2*a + 2*t1+2*d;i+=2)
                                   {
                                       res[i] = 2;
                                       res[i+1] = 3;
                                   }
                                   if(f==1)
                                       w.print("1 ");
                                   for(int i=0;i<a+b+c+d;i++)
                                   {
                                       if(f==1 && t2 == d+1)
                                       {
                                           if(i==a+b+c +d-2)
                                               break;
                                       }
                                       else
                                       {
                                           if(f==1 || t2 == d+1)
                                           {
                                               if(i==a+b+c +d-1)
                                               break;
                                           }
                                       }
                                       w.print(res[i] + " ");
                                   }
                                   if(t2 == d+1)
                                       w.print("2");
                                }
                                else
                                    w.println("NO");
                                }
                            }

                            else
                            {

                                w.println("NO");
                            }
                        }
                        else
                            w.println("NO");

                       }
                       }

       w.close();

    }
    public static int upperBound(int []arr,int n,int num)
    {
        int l = 0;
        int r = n;
        while(l < r)
        {
            int mid = (l+r)/2;
            if(num >= arr[mid])
            {
                l = mid +1;
            }
            else
                r = mid;
        }
        return l;
    }
    public static int countSetBits(int number){
        int count = 0;
        while(number>0){
            ++count;
            number &= number-1;
        }
        return count;
    }

     static  class CustomerSortingComparator
                                implements Comparator<Temp> {

    @Override
    public int compare(Temp cust1, Temp cust2) {

        // all comparison
        int compareName = 0;
        if(cust1.a < cust2.a)
            return 1;

        else if(cust1.a > cust2.a)
        return -1;
        else
        {
            if(cust1.b < cust2.b)
                return 1;
            else
                return -1;

        }

        }

    }

    public static long pow(long i, long j) {
		long res=1L;
		for(int a=0;a<j;a++) res*=i;
		return res;
	}
    public static long powmod(long i, long j,long MOD) {
		if(j==0) return 1L;
		if(j%2==0) {
			long temp=powmod(i,j/2,MOD);
			return (temp*temp)%MOD;
		}
		return (i*powmod(i,j-1,MOD))%MOD;
	}
    static HashSet<Integer> fac;
    public static void primeFactors(int n)
    {
        // Print the number of 2s that divide n
        int t = 0;
        while (n%2==0)
        {
            fac.add(2);
            n /= 2;
        }

        // n must be odd at this point.  So we can
        // skip one element (Note i = i +2)
        for (int i = 3; i*i <= n; i+= 2)
        {
            // While i divides n, print i and divide n
            while (n%i == 0)
            {
                fac.add(i);
                n /= i;
            }
        }

        // This condition is to handle the case whien
        // n is a prime number greater than 2
        if (n > 2)
            fac.add(n);
    }
     static long modexp(long x,long n,long M)
{
    long power = n;
    long result=1;
    x = x%M;
    while(power>0)
    {
        if(power % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        power = power/2;
    }
    return result;
}
    static long gcd(long a,long b)
    {
        if(a==0)
            return b;
        else
            return gcd(b%a,a);
    }
    static class Temp{
        int a;
        int b;
        int c;
        int d;

        Temp(int a,int b,int c,int d)
        {
            this.a = a;
            this.b = b;
            this.c  =c;
            this.d = d;
            //this.d = d;
        }
    }
    static class Query{
        int p;
        int index;
        int value;
        public Query(int p,int index,int value)
        {
            this.p = p;
            this.index = index;
            this.value = value;

        }
    }
    static int nextPowerOf2(int n)
    {
        int count = 0;

        // First n in the below
        // condition is for the
        // case where n is 0
        if (n > 0 && (n & (n - 1)) == 0)
            return n;

        while(n != 0)
        {
            n >>= 1;
            count += 1;
        }

        return 1 << count;
    }

   static long sum1(int t1,int t2,int x,int []t)
   {
       int mid = (t2-t1+1)/2;
  if(t1==t2)
      return 0;

   else
   return sum1(t1,mid-1,x,t) + sum1(mid,t2,x,t);

   }

    static String replace(String s,int a,int n)
    {
        char []c = s.toCharArray();
        for(int i=1;i<n;i+=2)
        {
            int num = (int) (c[i] - 48);
            num += a;
            num%=10;
            c[i] = (char) (num+48);
        }
        return new String(c);
    }
    static String move(String s,int h,int n)
    {
        h%=n;
        char []c = s.toCharArray();
        char []temp = new char[n];
        for(int i=0;i<n;i++)
        {
            temp[(i+h)%n] = c[i];
        }
        return new String(temp);
    }

     public static int ip(String s){
return Integer.parseInt(s);
}
     static class multipliers implements Comparator<Long>{

  public int compare(Long a,Long b) {
   if(a<b)
    return 1;
   else if(b<a)
    return -1;
   else
    return 0;
  }
 }
     static class multipliers1 implements Comparator<Student>{

  public int compare(Student a,Student b) {
   if(a.y<b.y)
    return 1;
   else if(b.y<a.y)
    return -1;
   else
   {
       if(a.id < b.id)
           return 1;
       else if(b.id<a.id)
           return -1;
       else
           return 0;

    //return 0;
   }
  }
 }
    // Java program to generate power set in
// lexicographic order.

      static class InputReader {

private final InputStream stream;
private final byte[] buf = new byte[8192];
private int curChar, snumChars;

public InputReader(InputStream st) {
this.stream = st;
}

public int read() {
if (snumChars == -1)
throw new InputMismatchException();
if (curChar >= snumChars) {
curChar = 0;
try {
snumChars = stream.read(buf);
} catch (IOException e) {
throw new InputMismatchException();
}
if (snumChars <= 0)
return -1;
}
return buf[curChar++];
}

public int ni() {
int c = read();
while (isSpaceChar(c)) {
c = read();
}
int sgn = 1;
if (c == '-') {
sgn = -1;
c = read();
}
int res = 0;
do {
res *= 10;
res += c - '0';
c = read();
} while (!isSpaceChar(c));
return res * sgn;
}

public long nl() {
int c = read();
while (isSpaceChar(c)) {
c = read();
}
int sgn = 1;
if (c == '-') {
sgn = -1;
c = read();
}
long res = 0;
do {
res *= 10;
res += c - '0';
c = read();
} while (!isSpaceChar(c));
return res * sgn;
}

public int[] nia(int n) {
int a[] = new int[n];
for (int i = 0; i < n; i++) {
a[i] = ni();
}
return a;
}

public String rs() {
int c = read();
while (isSpaceChar(c)) {
c = read();
}
StringBuilder res = new StringBuilder();
do {
res.appendCodePoint(c);
c = read();
} while (!isSpaceChar(c));
return res.toString();
}

public String nextLine() {
int c = read();
while (isSpaceChar(c))
c = read();
StringBuilder res = new StringBuilder();
do {
res.appendCodePoint(c);
c = read();
} while (!isEndOfLine(c));
return res.toString();
}

public boolean isSpaceChar(int c) {
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}

private boolean isEndOfLine(int c) {
return c == '\n' || c == '\r' || c == -1;
}

}

static PrintWriter w = new PrintWriter(System.out);
                  static class Student
    {
        int id;
        //int x;

        int y;
        //long z;

        Student(int id,int y)
        {
            this.id = id;
            //this.x = x;
            //this.s = s;
            this.y = y;
           // this.z = z;

        }

    }
}


import java.io.*;
import java.util.*;

public class compete604d {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());

		int[] val = new int[4];
		for(int j = 0; j < 4; j++) {
			val[j] = Integer.parseInt(st.nextToken());
		}
	 List<Integer> res = getRes(val);
             if(res==null)
                 System.out.println("NO");
             else
             {
                 System.out.println("YES");
			for(int v : res) {
				System.out.print(v + " ");
			}
             }

	}
	public static List<Integer> getRes(int []val)
    {
        LinkedList<Integer> res1 = new LinkedList<>();
        while(val[2] > 0 && val[3] > 0)
        {
            res1.addLast(2);
           res1.addLast(3);
           val[2]--;
           val[3]--;

        }
        LinkedList<Integer> res2 = new LinkedList<>();
        while(val[0] > 0 && val[1] > 0)
        {
            res2.addFirst(1);
           res2.addFirst(0);
           val[1]--;
           val[0]--;

        }
        while(val[1] > 0 && val[2] > 0)
        {
            res2.addLast(2);
           res2.addLast(1);
           val[2]--;
           val[1]--;

        }
        if(res1.isEmpty() && val[0] > 0)
        {
            res2.addLast(0);
            val[0]--;
        }
        if(res2.isEmpty() && val[3] > 0)
        {
            res1.addFirst(3);
            val[3]--;
        }
        res2.addAll(res1);
        if(val[2] > 0 && (res2.isEmpty() || res2.getLast() != 0))
        {
            res2.add(2);
            val[2]--;
        }
        if(val[1] > 0 && (res2.isEmpty() || res2.getFirst() != 3))
        {
            res2.add(1);
            val[1]--;
        }
        if(val[0] + val[1] + val[2] + val[3] > 0)
            return null;
        else
            return res2;

    }
}


//package learning;
import java.util.*;
import java.io.*;
import java.lang.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class NitsLocal {
    static ArrayList<String> s1;
    static boolean[] prime;
    static int n = (int)1e7;

     static void sieve() {
Arrays.fill(prime	, true);
prime[0] = prime[1] = false;
for(int i = 2 ; i * i <= n ; ++i) {
if(prime[i]) {
for(int k = i * i; k<= n ; k+=i) {
prime[k] = false;
}
}
}

}
    public static void main(String[] args) {
        InputReader sc = new InputReader(System.in);

           prime  = new boolean[n + 1];
           //sieve();
                prime[1] = false;
                /*
              int n = sc.ni();
              int []a = sc.nia(n);
              int mod = 1000000007;
              long ans = 0;
              int f = 0;
              int q = sc.ni();
              while(q-- > 0)
              {
                  int num = sc.ni();
                  ans = 0;
                  if(num == 0)
                  {
                      a[sc.ni()-1] = sc.ni();
                  }
                 else
                  {
                      int l = sc.ni();
                      int r = sc.ni();
                    for(int i=l-1;i<r;i++)
                   {

                   for(int j=i+1;j<r;j++)
                   {
                      f = 0;

                      int x = a[i];
                      int y = a[j];
                      while(x > 0 && y > 0)
                      {
                          int y1 = x%10;
                          int y2 = y%10;
                          if(y1 > 0 && y2 > 0)
                          {
                              f = 1;
                          }
                          x /= 10;
                          y /= 10;
                      }

                     if(f==0)
                     {
                         ans = (ans + ((((long)a[i]%mod) * ((long)a[j]%mod)))%mod)%mod;
                     }
                  }
              }

              w.println(ans);
                  }
              }

            */
                /*
               int t  = sc.ni();
               while(t-- > 0)
               {
                   int n = sc.ni();
                   Student []st = new Student[n];
                   for(int i=0;i<n;i++)
                   {
                       st[i] = new Student(sc.ni(),sc.ni());
                   }
                   Arrays.sort(st,(p,q)->p.id-q.id);
                   if(n==1)
                       w.println("0");
                   else
                   {
                    int prev = 0;
                    int adv = 0;
                    int max = -1;
                    int min = 1000000000;
                    for(int i=0;i<n;i++)
                    {
                        min = Math.min(st[i].y,min);
                        max = Math.max(st[i].y,max);
                    }
                        if(st[0].y > st[1].y)
                        {
                            prev = st[0].id;
                        }
                        else
                            prev= st[0].y;
                         if(st[n-1].id < st[n-2].y)
                        {
                            adv = st[n-1].id;
                        }
                        else
                            prev= st[n-1].y;
                         w.println(adv-prev);

                   }
               }
             */int []val = new int[4];
             for(int i=0;i<4;i++)
             {
                 val[i] = sc.ni();
             }

             List<Integer> res = getRes(val);
             if(res==null)
                 w.println("NO");
             else
             {
                 w.println("YES");
                 for(int i=0;i<res.size();i++)
                 {
                     w.print(res.get(i) + " ");
                 }
             }

       w.close();

    }
    public static List<Integer> getRes(int[] vals){
		LinkedList<Integer> res1 = new LinkedList<Integer>();
		while(vals[3] > 0 && vals[2] > 0) {
			res1.addLast(2);
			res1.addLast(3);
			vals[2]--;
			vals[3]--;
		}

		LinkedList<Integer> res2 = new LinkedList<Integer>();
		while(vals[0] > 0 && vals[1] > 0) {
			res2.addFirst(1);
			res2.addFirst(0);
			vals[1]--;
			vals[0]--;
		}

		while(vals[1] > 0 && vals[2] > 0) {
			res2.addLast(2);
			res2.addLast(1);
			vals[2]--;
			vals[1]--;
		}
		if(vals[0] > 0 && res1.isEmpty()) {
			res2.addLast(0);
			vals[0]--;
		}
		if(vals[3] > 0 && res2.isEmpty()) {
			res1.addFirst(3);
			vals[3]--;
		}

		res2.addAll(res1);
		if(vals[2] > 0 && (res2.isEmpty() || res2.getLast() != 0)) {
			res2.addLast(2);
			vals[2]--;
		}
		if(vals[1] > 0 && (res2.isEmpty() || res2.getFirst() != 3)) {
			res2.addFirst(1);
			vals[1]--;
		}
		if(vals[0] + vals[1] + vals[2] + vals[3] > 0) {
			return null;
		}
		return res2;
	}

    public static int upperBound(int []arr,int n,int num)
    {
        int l = 0;
        int r = n;
        while(l < r)
        {
            int mid = (l+r)/2;
            if(num >= arr[mid])
            {
                l = mid +1;
            }
            else
                r = mid;
        }
        return l;
    }
    public static int countSetBits(int number){
        int count = 0;
        while(number>0){
            ++count;
            number &= number-1;
        }
        return count;
    }

     static  class CustomerSortingComparator
                                implements Comparator<Temp> {

    @Override
    public int compare(Temp cust1, Temp cust2) {

        // all comparison
        int compareName = 0;
        if(cust1.a < cust2.a)
            return 1;

        else if(cust1.a > cust2.a)
        return -1;
        else
        {
            if(cust1.b < cust2.b)
                return 1;
            else
                return -1;

        }

        }

    }

    public static long pow(long i, long j) {
		long res=1L;
		for(int a=0;a<j;a++) res*=i;
		return res;
	}
    public static long powmod(long i, long j,long MOD) {
		if(j==0) return 1L;
		if(j%2==0) {
			long temp=powmod(i,j/2,MOD);
			return (temp*temp)%MOD;
		}
		return (i*powmod(i,j-1,MOD))%MOD;
	}
    static HashSet<Integer> fac;
    public static void primeFactors(int n)
    {
        // Print the number of 2s that divide n
        int t = 0;
        while (n%2==0)
        {
            fac.add(2);
            n /= 2;
        }

        // n must be odd at this point.  So we can
        // skip one element (Note i = i +2)
        for (int i = 3; i*i <= n; i+= 2)
        {
            // While i divides n, print i and divide n
            while (n%i == 0)
            {
                fac.add(i);
                n /= i;
            }
        }

        // This condition is to handle the case whien
        // n is a prime number greater than 2
        if (n > 2)
            fac.add(n);
    }
     static long modexp(long x,long n,long M)
{
    long power = n;
    long result=1;
    x = x%M;
    while(power>0)
    {
        if(power % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        power = power/2;
    }
    return result;
}
    static long gcd(long a,long b)
    {
        if(a==0)
            return b;
        else
            return gcd(b%a,a);
    }
    static class Temp{
        int a;
        int b;
        int c;
        int d;

        Temp(int a,int b,int c,int d)
        {
            this.a = a;
            this.b = b;
            this.c  =c;
            this.d = d;
            //this.d = d;
        }
    }
    static class Query{
        int p;
        int index;
        int value;
        public Query(int p,int index,int value)
        {
            this.p = p;
            this.index = index;
            this.value = value;

        }
    }
    static int nextPowerOf2(int n)
    {
        int count = 0;

        // First n in the below
        // condition is for the
        // case where n is 0
        if (n > 0 && (n & (n - 1)) == 0)
            return n;

        while(n != 0)
        {
            n >>= 1;
            count += 1;
        }

        return 1 << count;
    }

   static long sum1(int t1,int t2,int x,int []t)
   {
       int mid = (t2-t1+1)/2;
  if(t1==t2)
      return 0;

   else
   return sum1(t1,mid-1,x,t) + sum1(mid,t2,x,t);

   }

    static String replace(String s,int a,int n)
    {
        char []c = s.toCharArray();
        for(int i=1;i<n;i+=2)
        {
            int num = (int) (c[i] - 48);
            num += a;
            num%=10;
            c[i] = (char) (num+48);
        }
        return new String(c);
    }
    static String move(String s,int h,int n)
    {
        h%=n;
        char []c = s.toCharArray();
        char []temp = new char[n];
        for(int i=0;i<n;i++)
        {
            temp[(i+h)%n] = c[i];
        }
        return new String(temp);
    }

     public static int ip(String s){
return Integer.parseInt(s);
}
     static class multipliers implements Comparator<Long>{

  public int compare(Long a,Long b) {
   if(a<b)
    return 1;
   else if(b<a)
    return -1;
   else
    return 0;
  }
 }
     static class multipliers1 implements Comparator<Student>{

  public int compare(Student a,Student b) {
   if(a.y<b.y)
    return 1;
   else if(b.y<a.y)
    return -1;
   else
   {
       if(a.id < b.id)
           return 1;
       else if(b.id<a.id)
           return -1;
       else
           return 0;

    //return 0;
   }
  }
 }
    // Java program to generate power set in
// lexicographic order.

      static class InputReader {

private final InputStream stream;
private final byte[] buf = new byte[8192];
private int curChar, snumChars;

public InputReader(InputStream st) {
this.stream = st;
}

public int read() {
if (snumChars == -1)
throw new InputMismatchException();
if (curChar >= snumChars) {
curChar = 0;
try {
snumChars = stream.read(buf);
} catch (IOException e) {
throw new InputMismatchException();
}
if (snumChars <= 0)
return -1;
}
return buf[curChar++];
}

public int ni() {
int c = read();
while (isSpaceChar(c)) {
c = read();
}
int sgn = 1;
if (c == '-') {
sgn = -1;
c = read();
}
int res = 0;
do {
res *= 10;
res += c - '0';
c = read();
} while (!isSpaceChar(c));
return res * sgn;
}

public long nl() {
int c = read();
while (isSpaceChar(c)) {
c = read();
}
int sgn = 1;
if (c == '-') {
sgn = -1;
c = read();
}
long res = 0;
do {
res *= 10;
res += c - '0';
c = read();
} while (!isSpaceChar(c));
return res * sgn;
}

public int[] nia(int n) {
int a[] = new int[n];
for (int i = 0; i < n; i++) {
a[i] = ni();
}
return a;
}

public String rs() {
int c = read();
while (isSpaceChar(c)) {
c = read();
}
StringBuilder res = new StringBuilder();
do {
res.appendCodePoint(c);
c = read();
} while (!isSpaceChar(c));
return res.toString();
}

public String nextLine() {
int c = read();
while (isSpaceChar(c))
c = read();
StringBuilder res = new StringBuilder();
do {
res.appendCodePoint(c);
c = read();
} while (!isEndOfLine(c));
return res.toString();
}

public boolean isSpaceChar(int c) {
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}

private boolean isEndOfLine(int c) {
return c == '\n' || c == '\r' || c == -1;
}

}

static PrintWriter w = new PrintWriter(System.out);
                  static class Student
    {
        int id;
        //int x;

        int y;
        //long z;

        Student(int id,int y)
        {
            this.id = id;
            //this.x = x;
            //this.s = s;
            this.y = y;
           // this.z = z;

        }

    }
}


import java.util.*;
import java.io.*;
public class D {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		int[] in = new int[4];
		int tot = 0;
		for(int i = 0; i < 4; i++){
			in[i] = sc.nextInt();
			tot += in[i];
		}
		if(tot % 2 == 0) {
			if(in[0]+in[2] != in[1]+in[3]) {
				pw.write("NO\n");
			}
			else {
				int[] arr1 = seqev(in, tot);
				if(verify(arr1, tot)) {
					print(pw, arr1);
				}
				else {
					int[] arr2 = seqod(in, tot);
					if(verify(arr2, tot)) {
						print(pw, arr2);
					}
					else {
						pw.write("NO\n");
					}
				}
			}
		}
		else {
			if(in[0]+in[2] > in[1]+in[3]) {
				int[] arr = seqev(in, tot);
				if(verify(arr, tot)) {
					print(pw, arr);
				}
				else {
					pw.write("NO\n");
				}
			}
			else {
				int[] arr = seqod(in, tot);
				if(verify(arr, tot)) {
					print(pw, arr);
				}
				else {
					pw.write("NO\n");
				}
			}
		}
		pw.flush();
	}
	static boolean verify(int[] arr, int n) {
		for(int i = 1; i < n; i++) {
			if(Math.abs(arr[i] - arr[i-1]) > 1) {
				return false;
			}
		}
		return true;
	}
	static void print(PrintWriter pw, int[] arr) {
		StringBuilder sb = new StringBuilder();
		for(int k: arr) sb.append(k+" ");
		pw.write("YES\n");
		pw.write(sb.toString().trim()+"\n");
	}
	static int[] seqev(int[] cs, int n) {
		int[] ans = new int[n];
		Arrays.fill(ans, -1);
		for(int i = 0; i < cs[0]; i++) {
			ans[2*i] = 0;
		}
		for(int i = cs[0]; i < cs[0]+cs[2]; i++) {
			ans[2*i] = 2;
		}
		for(int i = 0; i < cs[1]; i++) {
			ans[2*i+1] = 1;
		}
		for(int i = cs[1]; i < cs[1]+cs[3]; i++) {
			ans[2*i+1] = 3;
		}
		return ans;
	}
	static int[] seqod(int[] cs, int n) {
		int[] ans = new int[n];
		Arrays.fill(ans, -1);
		for(int i = 0; i < cs[3]; i++) {
			ans[2*i] = 3;
		}
		for(int i = cs[3]; i < cs[3]+cs[1]; i++) {
			ans[2*i] = 1;
		}
		for(int i = 0; i < cs[2]; i++) {
			ans[2*i+1] = 2;
		}
		for(int i = cs[1]; i < cs[2]+cs[0]; i++) {
			ans[2*i+1] = 0;
		}
		return ans;
	}
	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch(IOException e) {
				throw new RuntimeException(e);
			}
		}
	}

}


import java.util.*;
import java.io.*;
public class D {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		int[] in = new int[4];
		int tot = 0;
		for(int i = 0; i < 4; i++){
			in[i] = sc.nextInt();
			tot += in[i];
		}
		if(tot % 2 == 0) {
			if(in[0]+in[2] != in[1]+in[3]) {
				pw.write("NO\n");
			}
			else {
				int[] arr1 = seqev(in, tot);
				if(verify(arr1, tot)) {
					print(pw, arr1);
				}
				else {
					int[] arr2 = seqod(in, tot);
					if(verify(arr2, tot)) {
						print(pw, arr2);
					}
					else {
						pw.write("NO\n");
					}
				}
			}
		}
		else {
			if(in[0]+in[2] > in[1]+in[3]) {
				int[] arr = seqev(in, tot);
				if(verify(arr, tot)) {
					print(pw, arr);
				}
				else {
					pw.write("NO\n");
				}
			}
			else {
				int[] arr = seqod(in, tot);
				if(verify(arr, tot)) {
					print(pw, arr);
				}
				else {
					pw.write("NO\n");
				}
			}
		}
		pw.flush();
	}
	static boolean verify(int[] arr, int n) {
		for(int i = 1; i < n; i++) {
			if(Math.abs(arr[i] - arr[i-1]) > 1) {
				return false;
			}
		}
		return true;
	}
	static void print(PrintWriter pw, int[] arr) {
		StringBuilder sb = new StringBuilder();
		for(int k: arr) sb.append(k+" ");
		pw.write(sb.toString().trim()+"\n");
	}
	static int[] seqev(int[] cs, int n) {
		int[] ans = new int[n];
		Arrays.fill(ans, -1);
		for(int i = 0; i < cs[0]; i++) {
			ans[2*i] = 0;
		}
		for(int i = cs[0]; i < cs[0]+cs[2]; i++) {
			ans[2*i] = 2;
		}
		for(int i = 0; i < cs[1]; i++) {
			ans[2*i+1] = 1;
		}
		for(int i = cs[1]; i < cs[1]+cs[3]; i++) {
			ans[2*i+1] = 3;
		}
		return ans;
	}
	static int[] seqod(int[] cs, int n) {
		int[] ans = new int[n];
		Arrays.fill(ans, -1);
		for(int i = 0; i < cs[3]; i++) {
			ans[2*i] = 3;
		}
		for(int i = cs[3]; i < cs[3]+cs[1]; i++) {
			ans[2*i] = 1;
		}
		for(int i = 0; i < cs[2]; i++) {
			ans[2*i+1] = 2;
		}
		for(int i = cs[1]; i < cs[2]+cs[0]; i++) {
			ans[2*i+1] = 0;
		}
		return ans;
	}
	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch(IOException e) {
				throw new RuntimeException(e);
			}
		}
	}

}


import java.util.*;
import java.io.*;
public class D {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		int[] in = new int[4];
		int tot = 0;
		for(int i = 0; i < 4; i++){
			in[i] = sc.nextInt();
			tot += in[i];
		}
		if(tot % 2 == 0) {
			if(in[0]+in[2] != in[1]+in[3]) {
				pw.write("NO\n");
			}
			else {
				int[] arr1 = seqev(in, tot);
				if(verify(arr1, tot)) {
					print(pw, arr1);
				}
				else {
					int[] arr2 = seqod(in, tot);
					if(verify(arr2, tot)) {
						print(pw, arr2);
					}
					else {
						pw.write("NO\n");
					}
				}
			}
		}
		else {
			if(Math.abs(in[0]+in[2] - (in[1]+in[3]) ) > 1){
				pw.write("NO\n");
			}
			else if(in[0]+in[2] > in[1]+in[3]) {
				int[] arr = seqev(in, tot);
				if(verify(arr, tot)) {
					print(pw, arr);
				}
				else {
					pw.write("NO\n");
				}
			}
			else {
				int[] arr = seqod(in, tot);
				if(verify(arr, tot)) {
					print(pw, arr);
				}
				else {
					pw.write("NO\n");
				}
			}
		}
		pw.flush();
	}
	static boolean verify(int[] arr, int n) {
		for(int i = 1; i < n; i++) {
			if(Math.abs(arr[i] - arr[i-1]) > 1) {
				return false;
			}
		}
		return true;
	}
	static void print(PrintWriter pw, int[] arr) {
		StringBuilder sb = new StringBuilder();
		for(int k: arr) sb.append(k+" ");
		pw.write("YES\n");
		pw.write(sb.toString().trim()+"\n");
	}
	static int[] seqev(int[] cs, int n) {
		int[] ans = new int[n];
		Arrays.fill(ans, -1);
		for(int i = 0; i < cs[0]; i++) {
			ans[2*i] = 0;
		}
		for(int i = cs[0]; i < cs[0]+cs[2]; i++) {
			ans[2*i] = 2;
		}
		for(int i = 0; i < cs[1]; i++) {
			ans[2*i+1] = 1;
		}
		for(int i = cs[1]; i < cs[1]+cs[3]; i++) {
			ans[2*i+1] = 3;
		}
		return ans;
	}
	static int[] seqod(int[] cs, int n) {
		int[] ans = new int[n];
		Arrays.fill(ans, -1);
		for(int i = 0; i < cs[3]; i++) {
			ans[2*i] = 3;
		}
		for(int i = cs[3]; i < cs[3]+cs[1]; i++) {
			ans[2*i] = 1;
		}
		for(int i = 0; i < cs[2]; i++) {
			ans[2*i+1] = 2;
		}
		for(int i = cs[2]; i < cs[2]+cs[0]; i++) {
			ans[2*i+1] = 0;
		}
		return ans;
	}
	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch(IOException e) {
				throw new RuntimeException(e);
			}
		}
	}

}


import java.util.*;
import java.io.*;
public class D {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		int[] in = new int[4];
		int tot = 0;
		for(int i = 0; i < 4; i++){
			in[i] = sc.nextInt();
			tot += in[i];
		}
		if(tot % 2 == 0) {
			if(in[0]+in[2] != in[1]+in[3]) {
				pw.write("NO\n");
			}
			else {
				int[] arr1 = seqev(in, tot);
				if(verify(arr1, tot)) {
					print(pw, arr1);
				}
				else {
					int[] arr2 = seqod(in, tot);
					if(verify(arr2, tot)) {
						print(pw, arr2);
					}
					else {
						pw.write("NO\n");
					}
				}
			}
		}
		else {
			if(Math.abs(in[0]+in[2] - (in[1]+in[3]) ) > 1){
				pw.write("NO\n");
			}
			else if(in[0]+in[2] > in[1]+in[3]) {
				int[] arr = seqev(in, tot);
				if(verify(arr, tot)) {
					print(pw, arr);
				}
				else {
					pw.write("NO\n");
				}
			}
			else {
				int[] arr = seqod(in, tot);
				if(verify(arr, tot)) {
					print(pw, arr);
				}
				else {
					pw.write("NO\n");
				}
			}
		}
		pw.flush();
	}
	static boolean verify(int[] arr, int n) {
		for(int i = 1; i < n; i++) {
			if(Math.abs(arr[i] - arr[i-1]) > 1) {
				return false;
			}
		}
		return true;
	}
	static void print(PrintWriter pw, int[] arr) {
		StringBuilder sb = new StringBuilder();
		for(int k: arr) sb.append(k+" ");
		pw.write("YES\n");
		pw.write(sb.toString().trim()+"\n");
	}
	static int[] seqev(int[] cs, int n) {
		int[] ans = new int[n];
		Arrays.fill(ans, -1);
		for(int i = 0; i < cs[0]; i++) {
			ans[2*i] = 0;
		}
		for(int i = cs[0]; i < cs[0]+cs[2]; i++) {
			ans[2*i] = 2;
		}
		for(int i = 0; i < cs[1]; i++) {
			ans[2*i+1] = 1;
		}
		for(int i = cs[1]; i < cs[1]+cs[3]; i++) {
			ans[2*i+1] = 3;
		}
		return ans;
	}
	static int[] seqod(int[] cs, int n) {
		int[] ans = new int[n];
		Arrays.fill(ans, -1);
		for(int i = 0; i < cs[3]; i++) {
			ans[2*i] = 3;
		}
		for(int i = cs[3]; i < cs[3]+cs[1]; i++) {
			ans[2*i] = 1;
		}
		for(int i = 0; i < cs[2]; i++) {
			ans[2*i+1] = 2;
		}
		for(int i = cs[1]; i < cs[2]+cs[0]; i++) {
			ans[2*i+1] = 0;
		}
		return ans;
	}
	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch(IOException e) {
				throw new RuntimeException(e);
			}
		}
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class cf {

	public static void main(String[] args) throws NumberFormatException, IOException {
		Scanner sc = new Scanner();
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		while (a > 0 && b > 0) {
			sb.append("0 ");
			a--;
			sb.append("1 ");
			b--;
		}
		while (b > 0 && c > 0) {
			sb.append("2 ");
			c--;
			sb.append("1 ");
			b--;
		}
		while (c > 0 && d > 0) {
			sb.append("2 ");
			c--;
			sb.append("3 ");
			d--;
		}
		if (c > 0) {
			sb.append("2");
			c--;
		}
		if (b > 0) {
			sb.insert(0, "1 ");
			b--;
		}
		if (a + b + c + d != 0) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
			System.out.println(sb);
		}
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreElements())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class cf {

	public static void main(String[] args) throws NumberFormatException, IOException {
		Scanner sc = new Scanner();
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		while (a > 0 && b > 0) {
			sb.append("0 ");
			a--;
			sb.append("1 ");
			b--;
		}
		StringBuilder tsb = new StringBuilder();
		while (c > 0 && d > 0) {
			tsb.append("2 ");
			c--;
			tsb.append("3 ");
			d--;
		}
		while (b > 0 && c > 0) {
			sb.append("2 ");
			c--;
			sb.append("1 ");
			b--;
		}

		if (c > 0) {
			tsb.append("2 ");
			c--;
		}
		if (b > 0) {
			sb.insert(0, "1 ");
			b--;
		}
		sb.append(tsb);
		if (d != 0 && (sb.length() == 0 || sb.charAt(0) == '2')) {
			sb.insert(0, "3 ");
			d--;
		}
		if (a != 0 && (sb.length() == 0 || sb.charAt(sb.length() - 2) == '1')) {
			sb.append("0 ");
			a--;
		}
		if (a + b + c + d != 0) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
			System.out.println(sb);
		}
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreElements())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class cf {

	public static void main(String[] args) throws NumberFormatException, IOException {
		Scanner sc = new Scanner();
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		while (a > 0 && b > 0) {
			sb.append("0 ");
			a--;
			sb.append("1 ");
			b--;
		}
		StringBuilder tsb = new StringBuilder();
		while (c > 0 && d > 0) {
			tsb.append("2 ");
			c--;
			tsb.append("3 ");
			d--;
		}
		while (b > 0 && c > 0) {
			sb.append("2 ");
			c--;
			sb.append("1 ");
			b--;
		}

		if (c > 0) {
			tsb.append("2");
			c--;
		}
		if (b > 0) {
			sb.insert(0, "1 ");
			b--;
		}
		sb.append(tsb);
		if (d != 0 && (sb.length() == 0 || sb.charAt(0) == '2')) {
			sb.insert(0, "3 ");
			d--;
		}
		if (a != 0 && (sb.length() == 0 || sb.charAt(sb.length() - 2) == '1')) {
			sb.append("0");
			a--;
		}
		if (a + b + c + d != 0) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
			System.out.println(sb);
		}
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreElements())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class cf {

	public static void main(String[] args) throws NumberFormatException, IOException {
		Scanner sc = new Scanner();
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		while (a > 0 && b > 0) {
			sb.append("0 ");
			a--;
			sb.append("1 ");
			b--;
		}
		StringBuilder tsb = new StringBuilder();
		while (c > 0 && d > 0) {
			tsb.append("2 ");
			c--;
			tsb.append("3 ");
			d--;
		}
		while (b > 0 && c > 0) {
			sb.append("2 ");
			c--;
			sb.append("1 ");
			b--;
		}

		if (c > 0) {
			tsb.append("2");
			c--;
		}
		if (b > 0) {
			sb.insert(0, "1 ");
			b--;
		}
		sb.append(tsb);
		if (d != 0 && (sb.length() == 0 || sb.charAt(0) == '2')) {
			sb.insert(0, "3 ");
			d--;
		}
		if (a != 0 && (sb.length() == 0 || sb.charAt(sb.length() - 1) == '1')) {
			sb.append("0");
			a--;
		}
		if (a + b + c + d != 0) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
			System.out.println(sb);
		}
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreElements())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
	}

}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author LUCIANO
 */
import java.util.*;

public class Solve {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner in = new Scanner(System.in);
        int[] dig = new int[4];
        int[] n_dig = new int[4];
        int diff = 0;
        for (int i = 0; i < 4; i++) {
            dig[i] = in.nextInt();
            n_dig[i] = dig[i];
            if(dig[i] != 0) diff += 1;
        }
        if(diff < 2)
        {
            if(dig[0] + dig[1] + dig[2] + dig[3] == 1)
            {
                System.out.println("YES");
                for(int i = 0; i < 4; i++)
                {
                    if(dig[i] != 0)
                    {
                        System.out.println(i);
                        break;
                    }
                }
            }
            else System.out.println("NO");
            System.exit(0);
        }
        int[] seqA = new int[dig[0] + dig[1] + dig[2] + dig[3]];
        int[] seqB = new int[dig[0] + dig[1] + dig[2] + dig[3]];
        Arrays.fill(seqA, -5);
        Arrays.fill(seqB, -5);
        int first = -5;
        int second = -5;
        for (int i = 0; i < 4; i++) {
            if (dig[i] != 0 && first == -5) {
                first = i;
                continue;
            }
            if (dig[i] != 0 && first != -5) {
                second = i;
                break;
            }
        }
        int cntA = 0;
        int cntB = 0;
        for (int i = 0; i < seqA.length; i += 2) {
            if (cntA < dig[first]) {
                cntA += 1;
                seqA[i] = first;
            }
            if (cntB < dig[second]) {
                cntB += 1;
                seqB[i] = second;
            }
        }
        for (int i = 0; i < 4; i++) {
            if (dig[i] != 0 && i != first) {
                int add = 1;
                for (int j = 1; j < seqA.length; j += add) {
                    if (seqA[j] == -5) {
                        add = 2;
                        seqA[j] = i;
                        dig[i] -= 1;
                    }
                    if (dig[i] == 0) {
                        break;
                    }

                }
            }
        }
        for (int i = 0; i < 4; i++) {
            if (n_dig[i] != 0 && i != second) {
                int add = 1;
                for (int j = 1; j < seqB.length; j += add) {
                    if (seqB[j] == -5) {
                        add = 2;
                        seqB[j] = i;
                        n_dig[i] -= 1;
                    }
                    if (n_dig[i] == 0) {
                        break;
                    }

                }
            }
        }
        boolean a = true;
        boolean b = true;
        String yes_no = "YES";
        for (int i = 0; i < seqA.length - 1; i++) {
            if (Math.abs(seqA[i] - seqA[i + 1]) != 1) {
                a = false;
            }
            if (Math.abs(seqB[i] - seqB[i + 1]) != 1) {
                b = false;
            }
            if ((a || b) == false) {
                yes_no = "NO";
                break;
            }
        }
        if (a == true) {
            System.out.println(yes_no);
            for (int i = 0; i < seqA.length; i++) {
                if (i > 0) {
                    System.out.print(" ");
                }
                System.out.print(seqA[i]);
            }
        } else if (b == true) {
            System.out.println(yes_no);
            for (int i = 0; i < seqB.length; i++) {
                if (i > 0) {
                    System.out.print(" ");
                }
                System.out.print(seqB[i]);
            }
        } else {
            System.out.println(yes_no);
        }
    }

}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author LUCIANO
 */
import java.util.*;

public class Solve {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here

        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        for (int tt = 0; tt < t; tt++) {
            int n = in.nextInt();
            int[] seq = new int[n];
            for (int i = 0; i < n; i++) {
                seq[i] = in.nextInt();
            }
            int g = 0;
            int s = 0;
            int b = 0;
            int ref = seq[n / 2];
            int first = seq[0];
            boolean flag = true;
            for (int i = 0; i < (n / 2); i++) {
                if (seq[i] == ref) {
                    break;
                }
                if (seq[i] == first) {
                    g += 1;
                } else {
                    if (s > g && (seq[i] != seq[i - 1])) {
                        flag = false;
                    }
                    if (flag == true) {
                        s += 1;
                    } else {
                        b += 1;
                    }
                }
            }
            if (g < Math.min(s, b)) {
                System.out.println(g + " " + s + " " + b);
            } else {
                System.out.println(0 + " " + 0 + " " + 0);
            }
        }
    }
}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author LUCIANO
 */
import java.util.*;

public class Solve {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner in = new Scanner(System.in);
        int[] dig = new int[4];
        int[] n_dig = new int[4];
        boolean[] d = new boolean[4];
        Arrays.fill(d, false);
        for (int i = 0; i < 4; i++) {
            dig[i] = in.nextInt();
        }
        int[] seqA = new int[dig[0] + dig[1] + dig[2] + dig[3]];
        int[] seqB = new int[dig[0] + dig[1] + dig[2] + dig[3]];
        Arrays.fill(seqA, -5);
        Arrays.fill(seqB, -5);
        int first = -5;
        int second = -5;
        for (int i = 0; i < 4; i++) {
            if (dig[i] != 0 && first == -5) {
                first = i;
                continue;
            }
            if (dig[i] != 0 && first != -5) {
                second = i;
                break;
            }
        }
        n_dig[first] = dig[first];
        int cntA = 0;
        int cntB = 0;
        for (int i = 0; i < seqA.length; i += 2) {
            if (cntA < dig[first]) {
                cntA += 1;
                seqA[i] = first;
            }
            if (cntB < dig[second]) {
                cntB += 1;
                seqB[i] = second;
            }
        }
        for (int i = 0; i < 4; i++) {
            if (dig[i] != 0 && i != first) {
                int add = 1;
                for (int j = 1; j < seqA.length; j += add) {
                    if (seqA[j] == -5) {
                        add = 2;
                        seqA[j] = i;
                        dig[i] -= 1;
                        n_dig[i] += 1;
                    }
                    if (dig[i] == 0) {
                        break;
                    }

                }
            }
        }
        for (int i = 0; i < 4; i++) {
            if (n_dig[i] != 0 && i != second) {
                int add = 1;
                for (int j = 1; j < seqB.length; j += add) {
                    if (seqB[j] == -5) {
                        add = 2;
                        seqB[j] = i;
                        n_dig[i] -= 1;
                    }
                    if (n_dig[i] == 0) {
                        break;
                    }

                }
            }
        }
        boolean a = true;
        boolean b = true;
        String yes_no = "YES";
        for (int i = 0; i < seqA.length - 1; i++) {
            if (Math.abs(seqA[i] - seqA[i + 1]) != 1) {
                a = false;
            }
            if (Math.abs(seqB[i] - seqB[i + 1]) != 1) {
                b = false;
            }
            if ((a || b) == false) {
                yes_no = "NO";
                break;
            }
        }
        if (a == true) {
            System.out.println(yes_no);
            for (int i = 0; i < seqA.length; i++) {
                if (i > 0) {
                    System.out.print(" ");
                }
                System.out.print(seqA[i]);
            }
        } else if (b == true) {
            System.out.println(yes_no);
            for (int i = 0; i < seqB.length; i++) {
                if (i > 0) {
                    System.out.print(" ");
                }
                System.out.print(seqB[i]);
            }
        } else {
            System.out.println(yes_no);
        }
    }

}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author LUCIANO
 */
import java.util.*;

public class Solve {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner in = new Scanner(System.in);
        int[] dig = new int[4];
        int[] n_dig = new int[4];
        boolean[] d = new boolean[4];
        Arrays.fill(d, false);
        for (int i = 0; i < 4; i++) {
            dig[i] = in.nextInt();
            n_dig[i] = dig[i];
        }
        int[] seqA = new int[dig[0] + dig[1] + dig[2] + dig[3]];
        int[] seqB = new int[dig[0] + dig[1] + dig[2] + dig[3]];
        Arrays.fill(seqA, -5);
        Arrays.fill(seqB, -5);
        int first = -5;
        int second = -5;
        for (int i = 0; i < 4; i++) {
            if (dig[i] != 0 && first == -5) {
                first = i;
                continue;
            }
            if (dig[i] != 0 && first != -5) {
                second = i;
                break;
            }
        }
        int cntA = 0;
        int cntB = 0;
        for (int i = 0; i < seqA.length; i += 2) {
            if (cntA < dig[first]) {
                cntA += 1;
                seqA[i] = first;
            }
            if (cntB < dig[second]) {
                cntB += 1;
                seqB[i] = second;
            }
        }
        for (int i = 0; i < 4; i++) {
            if (dig[i] != 0 && i != first) {
                int add = 1;
                for (int j = 1; j < seqA.length; j += add) {
                    if (seqA[j] == -5) {
                        add = 2;
                        seqA[j] = i;
                        dig[i] -= 1;
                    }
                    if (dig[i] == 0) {
                        break;
                    }

                }
            }
        }
        for (int i = 0; i < 4; i++) {
            if (n_dig[i] != 0 && i != second) {
                int add = 1;
                for (int j = 1; j < seqB.length; j += add) {
                    if (seqB[j] == -5) {
                        add = 2;
                        seqB[j] = i;
                        n_dig[i] -= 1;
                    }
                    if (n_dig[i] == 0) {
                        break;
                    }

                }
            }
        }
        boolean a = true;
        boolean b = true;
        String yes_no = "YES";
        for (int i = 0; i < seqA.length - 1; i++) {
            if (Math.abs(seqA[i] - seqA[i + 1]) != 1) {
                a = false;
            }
            if (Math.abs(seqB[i] - seqB[i + 1]) != 1) {
                b = false;
            }
            if ((a || b) == false) {
                yes_no = "NO";
                break;
            }
        }
        if (a == true) {
            System.out.println(yes_no);
            for (int i = 0; i < seqA.length; i++) {
                if (i > 0) {
                    System.out.print(" ");
                }
                System.out.print(seqA[i]);
            }
        } else if (b == true) {
            System.out.println(yes_no);
            for (int i = 0; i < seqB.length; i++) {
                if (i > 0) {
                    System.out.print(" ");
                }
                System.out.print(seqB[i]);
            }
        } else {
            System.out.println(yes_no);
        }
    }

}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author LUCIANO
 */
import java.util.*;

public class Solve {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner in = new Scanner(System.in);
        int[] dig = new int[4];
        int[] n_dig = new int[4];
        int diff = 0;
        for (int i = 0; i < 4; i++) {
            dig[i] = in.nextInt();
            n_dig[i] = dig[i];
            if(dig[i] != 0) diff += 1;
        }
        if(diff < 2)
        {
            if(dig[0] + dig[1] + dig[2] + dig[3] == 1)
            System.out.println("YES");
            else System.out.println("NO");
            System.exit(0);
        }
        int[] seqA = new int[dig[0] + dig[1] + dig[2] + dig[3]];
        int[] seqB = new int[dig[0] + dig[1] + dig[2] + dig[3]];
        Arrays.fill(seqA, -5);
        Arrays.fill(seqB, -5);
        int first = -5;
        int second = -5;
        for (int i = 0; i < 4; i++) {
            if (dig[i] != 0 && first == -5) {
                first = i;
                continue;
            }
            if (dig[i] != 0 && first != -5) {
                second = i;
                break;
            }
        }
        int cntA = 0;
        int cntB = 0;
        for (int i = 0; i < seqA.length; i += 2) {
            if (cntA < dig[first]) {
                cntA += 1;
                seqA[i] = first;
            }
            if (cntB < dig[second]) {
                cntB += 1;
                seqB[i] = second;
            }
        }
        for (int i = 0; i < 4; i++) {
            if (dig[i] != 0 && i != first) {
                int add = 1;
                for (int j = 1; j < seqA.length; j += add) {
                    if (seqA[j] == -5) {
                        add = 2;
                        seqA[j] = i;
                        dig[i] -= 1;
                    }
                    if (dig[i] == 0) {
                        break;
                    }

                }
            }
        }
        for (int i = 0; i < 4; i++) {
            if (n_dig[i] != 0 && i != second) {
                int add = 1;
                for (int j = 1; j < seqB.length; j += add) {
                    if (seqB[j] == -5) {
                        add = 2;
                        seqB[j] = i;
                        n_dig[i] -= 1;
                    }
                    if (n_dig[i] == 0) {
                        break;
                    }

                }
            }
        }
        boolean a = true;
        boolean b = true;
        String yes_no = "YES";
        for (int i = 0; i < seqA.length - 1; i++) {
            if (Math.abs(seqA[i] - seqA[i + 1]) != 1) {
                a = false;
            }
            if (Math.abs(seqB[i] - seqB[i + 1]) != 1) {
                b = false;
            }
            if ((a || b) == false) {
                yes_no = "NO";
                break;
            }
        }
        if (a == true) {
            System.out.println(yes_no);
            for (int i = 0; i < seqA.length; i++) {
                if (i > 0) {
                    System.out.print(" ");
                }
                System.out.print(seqA[i]);
            }
        } else if (b == true) {
            System.out.println(yes_no);
            for (int i = 0; i < seqB.length; i++) {
                if (i > 0) {
                    System.out.print(" ");
                }
                System.out.print(seqB[i]);
            }
        } else {
            System.out.println(yes_no);
        }
    }

}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author LUCIANO
 */
import java.util.*;

public class Solve {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner in = new Scanner(System.in);
        int[] dig = new int[4];
        int[] n_dig = new int[4];
        int diff = 0;
        for (int i = 0; i < 4; i++) {
            dig[i] = in.nextInt();
            n_dig[i] = dig[i];
            if(dig[i] != 0) diff += 1;
        }
        if(diff < 2)
        {
            System.out.println("NO");
            System.exit(0);
        }
        int[] seqA = new int[dig[0] + dig[1] + dig[2] + dig[3]];
        int[] seqB = new int[dig[0] + dig[1] + dig[2] + dig[3]];
        Arrays.fill(seqA, -5);
        Arrays.fill(seqB, -5);
        int first = -5;
        int second = -5;
        for (int i = 0; i < 4; i++) {
            if (dig[i] != 0 && first == -5) {
                first = i;
                continue;
            }
            if (dig[i] != 0 && first != -5) {
                second = i;
                break;
            }
        }
        int cntA = 0;
        int cntB = 0;
        for (int i = 0; i < seqA.length; i += 2) {
            if (cntA < dig[first]) {
                cntA += 1;
                seqA[i] = first;
            }
            if (cntB < dig[second]) {
                cntB += 1;
                seqB[i] = second;
            }
        }
        for (int i = 0; i < 4; i++) {
            if (dig[i] != 0 && i != first) {
                int add = 1;
                for (int j = 1; j < seqA.length; j += add) {
                    if (seqA[j] == -5) {
                        add = 2;
                        seqA[j] = i;
                        dig[i] -= 1;
                    }
                    if (dig[i] == 0) {
                        break;
                    }

                }
            }
        }
        for (int i = 0; i < 4; i++) {
            if (n_dig[i] != 0 && i != second) {
                int add = 1;
                for (int j = 1; j < seqB.length; j += add) {
                    if (seqB[j] == -5) {
                        add = 2;
                        seqB[j] = i;
                        n_dig[i] -= 1;
                    }
                    if (n_dig[i] == 0) {
                        break;
                    }

                }
            }
        }
        boolean a = true;
        boolean b = true;
        String yes_no = "YES";
        for (int i = 0; i < seqA.length - 1; i++) {
            if (Math.abs(seqA[i] - seqA[i + 1]) != 1) {
                a = false;
            }
            if (Math.abs(seqB[i] - seqB[i + 1]) != 1) {
                b = false;
            }
            if ((a || b) == false) {
                yes_no = "NO";
                break;
            }
        }
        if (a == true) {
            System.out.println(yes_no);
            for (int i = 0; i < seqA.length; i++) {
                if (i > 0) {
                    System.out.print(" ");
                }
                System.out.print(seqA[i]);
            }
        } else if (b == true) {
            System.out.println(yes_no);
            for (int i = 0; i < seqB.length; i++) {
                if (i > 0) {
                    System.out.print(" ");
                }
                System.out.print(seqB[i]);
            }
        } else {
            System.out.println(yes_no);
        }
    }

}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author LUCIANO
 */
import java.util.*;

public class Solve {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner in = new Scanner(System.in);
        int[] dig = new int[4];
        int[] n_dig = new int[4];
        boolean[] d = new boolean[4];
        Arrays.fill(d, false);
        for (int i = 0; i < 4; i++) {
            dig[i] = in.nextInt();
        }
        int[] seqA = new int[dig[0] + dig[1] + dig[2] + dig[3]];
        int[] seqB = new int[dig[0] + dig[1] + dig[2] + dig[3]];
        Arrays.fill(seqA, -5);
        Arrays.fill(seqB, -5);
        int first = -5;
        int second = -5;
        for (int i = 0; i < 4; i++) {
            if (dig[i] != 0 && first == -5) {
                first = i;
                continue;
            }
            if (dig[i] != 0 && first != -5) {
                second = i;
                break;
            }
        }
        n_dig[first] = dig[first];
        int cntA = 0;
        int cntB = 0;
        for (int i = 0; i < seqA.length; i += 2) {
            if (cntA < dig[first]) {
                cntA += 1;
                seqA[i] = first;
            }
            if (cntB < dig[second]) {
                cntB += 1;
                seqB[i] = second;
            }
        }
        for (int i = 0; i < 4; i++) {
            if (dig[i] != 0 && i != first) {
                int add = 1;
                for (int j = 1; j < seqA.length; j += add) {
                    if (seqA[j] == -5) {
                        add = 2;
                        seqA[j] = i;
                        dig[i] -= 1;
                        n_dig[i] += 1;
                    }
                    if (dig[i] == 0) {
                        break;
                    }

                }
            }
        }
        for (int i = 0; i < 4; i++) {
            if (n_dig[i] != 0 && i != second) {
                int add = 1;
                for (int j = 1; j < seqB.length; j += add) {
                    if (seqB[j] == -5) {
                        add = 2;
                        seqB[j] = i;
                        n_dig[i] -= 1;
                    }
                    if (n_dig[i] == 0) {
                        break;
                    }

                }
            }
        }
        boolean a = true;
        boolean b = true;
        String yes_no = "YES";
        String ansA = "";
        String ansB = "";
        for (int i = 0; i < seqA.length - 1; i++) {
            ansA = ansA + seqA[i] + " ";
            ansB = ansB + seqB[i] + " ";
            if (Math.abs(seqA[i] - seqA[i + 1]) != 1) {
                a = false;
            }
            if (Math.abs(seqB[i] - seqB[i + 1]) != 1) {
                b = false;
            }
            if ((a || b) == false) {
                yes_no = "NO";
                break;
            }
        }
        if (a == true) {
            System.out.println(yes_no);
            System.out.println(ansA + seqA[seqA.length - 1]);
        } else if (b == true) {
            System.out.println(yes_no);
            System.out.println(ansB + seqB[seqB.length - 1]);
        } else {
            System.out.println(yes_no);
        }
    }

}


#include <bits/stdc++.h>
#define MAXN 1000100
#define pii pair<int, int>
#define pb push_back
#define inf 1e18
#define fi first
#define se second
#define mt make_tuple
typedef long long ll;

using namespace std;

int n;
int lo[4 * MAXN + 1], hi[4 * MAXN + 1], tree[4 * MAXN + 1], delta[4 * MAXN + 1];
void init(int i, int l, int r){
	lo[i] = l;
	hi[i] = r;
	if(l == r) return;
	int m = (l + r) / 2;
	init(2 * i, l, m);
	init(2 * i + 1, m + 1, r);
}

void prop(int i){
	delta[2 * i] += delta[i];
	delta[2 * i + 1] += delta[i];
	delta[i] = 0;
}

void update(int i){
	tree[i] = max(tree[2 * i] + delta[2 * i], tree[2 * i + 1] + delta[2 * i + 1]);
}

void inc(int i, int l, int r, int val){
	if(r < lo[i] || hi[i] < l) return;
	if(hi[i] <= r && lo[i] >= l){
		delta[i] += val;
		return;
	}
	//partial cover case
	prop(i);
	inc(2 * i, l, r, val);
	inc(2 * i + 1, l, r, val);
	update(i);
}

int query(int i, int l, int r){
	if(r < lo[i] || hi[i] < l) return -MAXN;	//not in range
	if(hi[i] <= r && lo[i] >= l) return tree[i] + delta[i];	//completely in range
	prop(i);
	int maxLeft = query(2 * i, l, r);
	int maxRight = query(2 * i + 1, l, r);
	update(i);
	return max(maxLeft, maxRight);
}
int m, a[MAXN], b[MAXN];
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    init(1, 0, MAXN - 1);
    for(int i = 0; i < n; i++){
    	cin >> a[i];
    	inc(1, 0, a[i], 1);
    }
    for(int i = 0; i < m; i++){
    	cin >> b[i];
    	inc(1, 0, b[i], -1);
    }
    int q;
    cin >> q;
    for(int Q = 0; Q < q; Q++){
    	int t, i, x;
    	cin >> t >> i >> x;
    	i--;
    	if(t == 1){
    		inc(1, 0, a[i], -1);
    		a[i] = x;
    		inc(1, 0, a[i], 1);
    	} else{
    		inc(1, 0, b[i], 1);
    		b[i] = x;
    		inc(1, 0, b[i], -1);
    	}
    	int l = 0, r = MAXN - 1;
    	while(l < r){
    		int mid = (l + r) / 2;
    		if(query(1, mid, MAXN - 1) > 0){
    			l = mid + 1;
    		} else{
    			r = mid;
    		}
    	}
    	cout << l - 1 << endl;
    }
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
#define N 1000010
namespace seg{
    ll dat[2*N],laz[2*N];
    void init(){
	for(int i=0;i<2*N;i++){
	    dat[i]=0,laz[i]=0;
	}
    }
    ll eval(ll k){
	if(k<N){
	    laz[k*2]+=laz[k];
	    laz[k*2+1]+=laz[k];
	}
	dat[k]+=laz[k],laz[k]=0;
	return dat[k];
    }
    void upd(ll l,ll r,ll x){
	l+=N,r+=N+1;
	for(ll a=l,b=r;a<b;a>>=1,b>>=1){
	    if(a&1)laz[a++]+=x;
	    if(b&1)laz[--b]+=x;
	}
	for(ll a=l,b=r;a+b;a>>=1,b>>=1){
	    dat[a/2]=min(eval(a),eval(a^1));
	    dat[b/2]=min(eval(b),eval(b^1));
	}
    }
    ll qry(ll l,ll r){
	l+=N,r+=N+1;
	for(ll d=21;~d;d--){
	    eval(l>>d); eval(r>>d);
	}
	ll ans=1e17;
	for(ll a=l,b=r;a<b;a>>=1,b>>=1){
	    if(a&1)ans=min(ans,eval(a++));
	    if(b&1)ans=min(ans,eval(--b));
	}
	return ans;
    }
};
ll n,m,q,a[N],b[N];
int main(){
  cin>>n>>m;
  seg::init();
  for(int i=1;i<=n;i++){
      cin>>a[i];
      seg::upd(0,a[i],-1);
  }
  for(int i=1;i<=m;i++){
      cin>>b[i];
      seg::upd(0,b[i],+1);
  }//for(int i=0;i<110;i++)cout<<i<<":"<<seg::qry(i,N-3)<<endl;
  cin>>q;
  while(q--){
      ll t,i,x;
      cin>>t>>i>>x;
      if(t==1){
	  seg::upd(0,a[i],+1);
	  seg::upd(0,x,-1);
	  a[i]=x;
      }
      if(t==2){
	  seg::upd(0,b[i],-1);
	  seg::upd(0,x,+1);
	  b[i]=x;
      }
      //for(int i=0;i<110;i++)cout<<i<<":"<<seg::qry(i,N-3)<<endl;
      ll l=-1,r=N-3,mid;
      while(l<r-1){
	  mid=(l+r)>>1;
	  if(seg::qry(mid,N-3)<0)l=mid;
	  else r=mid;
      }
      printf("%lld\n",l);
  }
  return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
#define N 1000010
//namespace seg{
    ll dat[N];
    void init(){
	for(int i=0;i<2*N;i++){
	    dat[i]=0;
	}
    }
    void upd(ll i,ll x){
	i=N-1-i;
	i+=N;
	dat[i]+=x;
	while(i>1){
	    dat[i/2]+=x;
	    i>>=1;
	}
    }
    ll qry(ll i){
	i=N-1-i;
	ll ans=dat[i];
	while(i>1){
	    ans+=dat[i/2];
	    i>>=1;
	}
	return ans;
    }
//};
ll n,m,q,a[N],b[N];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  cin>>n>>m;
  init();
  for(int i=1;i<=n;i++){
      cin>>a[i];
      upd(a[i],-1);
  }
  for(int i=1;i<=m;i++){
      cin>>b[i];
      upd(b[i],+1);
  }//for(int i=0;i<110;i++)cout<<i<<":"<<seg::qry(i,N-3)<<endl;
  cin>>q;
  while(q--){
      ll t,i,x;
      cin>>t>>i>>x;
      if(t==1){
	  upd(a[i],+1);
	  upd(x,-1);
	  a[i]=x;
      }
      if(t==2){
	  upd(b[i],-1);
	  upd(x,+1);
	  b[i]=x;
      }
      //for(int i=0;i<110;i++)cout<<i<<":"<<seg::qry(i,N-3)<<endl;
      ll l=-1,r=N-3,mid;
      while(l<r-1){
	  mid=(l+r)>>1;
	  if(qry(mid)<0)l=mid;
	  else r=mid;
      }
      printf("%lld\n",l);
  }
  return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
#define N (1<<20)
//namespace seg{
    ll dat[2*N],laz[2*N];
    void init(){
	for(int i=0;i<2*N;i++){
	    dat[i]=0,laz[i]=0;
	}
    }
    ll eval(ll k){
	if(k<N){
	    laz[k*2]+=laz[k];
	    laz[k*2+1]+=laz[k];
	}
	dat[k]+=laz[k],laz[k]=0;
	return dat[k];
    }
    void upd(ll l,ll r,ll x){
	l+=N,r+=N+1;
	for(ll a=l,b=r;a<b;a>>=1,b>>=1){
	    if(a&1)laz[a++]+=x;
	    if(b&1)laz[--b]+=x;
	}
	for(ll a=l,b=r;a+b;a>>=1,b>>=1){
	    dat[a/2]=min(eval(a),eval(a^1));
	    dat[b/2]=min(eval(b),eval(b^1));
	}
    }
    ll qry(ll l,ll r,ll k){
	if(eval(k)>=0)return -1;
	if(l+1==r)return l;
	ll m=(l+r)>>1;
	ll vr=qry(m,r,k*2+1);
	if(~vr)return vr;
	return qry(l,m,k*2);
    }
//};
ll n,m,q,a[N],b[N];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  cin>>n>>m;
  init();
  for(int i=1;i<=n;i++){
      cin>>a[i];
      upd(0,a[i],-1);
  }
  for(int i=1;i<=m;i++){
      cin>>b[i];
      upd(0,b[i],+1);
  }//for(int i=0;i<110;i++)cout<<i<<":"<<seg::qry(i,N-3)<<endl;
  cin>>q;
  while(q--){
      ll t,i,x;
      cin>>t>>i>>x;
      if(t==1){
	  upd(0,a[i],+1);
	  upd(0,x,-1);
	  a[i]=x;
      }
      if(t==2){
	  upd(0,b[i],-1);
	  upd(0,x,+1);
	  b[i]=x;
      }
      //for(int i=0;i<110;i++)cout<<i<<":"<<seg::qry(i,N-3)<<endl;
      ll ans=qry(0,N,1);
      printf("%lld\n",ans);
  }
  return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
#define N 1000010
//namespace seg{
    ll dat[2*N],laz[2*N];
    void init(){
	for(int i=0;i<2*N;i++){
	    dat[i]=0,laz[i]=0;
	}
    }
    ll eval(ll k){
	if(k<N){
	    laz[k*2]+=laz[k];
	    laz[k*2+1]+=laz[k];
	}
	dat[k]+=laz[k],laz[k]=0;
	return dat[k];
    }
    void upd(ll l,ll r,ll x){
	l+=N,r+=N+1;
	for(ll a=l,b=r;a<b;a>>=1,b>>=1){
	    if(a&1)laz[a++]+=x;
	    if(b&1)laz[--b]+=x;
	}
	for(ll a=l,b=r;a+b;a>>=1,b>>=1){
	    dat[a/2]=min(eval(a),eval(a^1));
	    dat[b/2]=min(eval(b),eval(b^1));
	}
    }
    ll qry(ll l,ll r){
	l+=N,r+=N+1;
	for(ll d=20;~d;d--){
	    eval(l>>d); eval(r>>d);
	}
	ll ans=1e17;
	for(ll a=l,b=r;a<b;a>>=1,b>>=1){
	    if(a&1)ans=min(ans,eval(a++));
	    if(b&1)ans=min(ans,eval(--b));
	}
	return ans;
    }
//};
ll n,m,q,a[N],b[N];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  cin>>n>>m;
  init();
  for(int i=1;i<=n;i++){
      cin>>a[i];
      upd(0,a[i],-1);
  }
  for(int i=1;i<=m;i++){
      cin>>b[i];
      upd(0,b[i],+1);
  }//for(int i=0;i<110;i++)cout<<i<<":"<<seg::qry(i,N-3)<<endl;
  cin>>q;
  while(q--){
      ll t,i,x;
      cin>>t>>i>>x;
      if(t==1){
	  upd(0,a[i],+1);
	  upd(0,x,-1);
	  a[i]=x;
      }
      if(t==2){
	  upd(0,b[i],-1);
	  upd(0,x,+1);
	  b[i]=x;
      }
      //for(int i=0;i<110;i++)cout<<i<<":"<<seg::qry(i,N-3)<<endl;
      ll l=-1,r=N-3,mid;
      while(l<r-1){
	  mid=(l+r)>>1;
	  if(qry(mid,N-3)<0)l=mid;
	  else r=mid;
      }
      printf("%lld\n",l);
  }
  return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
#define N 1000010
namespace seg{
    ll dat[2*N],laz[2*N];
    void init(){
	for(int i=0;i<2*N;i++){
	    dat[i]=0,laz[i]=0;
	}
    }
    ll eval(ll k){
	if(k<N){
	    laz[k*2]+=laz[k];
	    laz[k*2+1]+=laz[k];
	}
	dat[k]+=laz[k],laz[k]=0;
	return dat[k];
    }
    void upd(ll l,ll r,ll x){
	l+=N,r+=N+1;
	for(ll a=l,b=r;a<b;a>>=1,b>>=1){
	    if(a&1)laz[a++]+=x;
	    if(b&1)laz[--b]+=x;
	}
	for(ll a=l,b=r;a+b;a>>=1,b>>=1){
	    dat[a/2]=min(eval(a),eval(a^1));
	    dat[b/2]=min(eval(b),eval(b^1));
	}
    }
    ll qry(ll l,ll r){
	l+=N,r+=N+1;
	for(ll d=21;~d;d--){
	    eval(l>>d); eval(r>>d);
	}
	ll ans=1e17;
	for(ll a=l,b=r;a<b;a>>=1,b>>=1){
	    if(a&1)ans=min(ans,eval(a++));
	    if(b&1)ans=min(ans,eval(--b));
	}
	return ans;
    }
};
ll n,m,q,a[N],b[N];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  cin>>n>>m;
  seg::init();
  for(int i=1;i<=n;i++){
      cin>>a[i];
      seg::upd(0,a[i],-1);
  }
  for(int i=1;i<=m;i++){
      cin>>b[i];
      seg::upd(0,b[i],+1);
  }//for(int i=0;i<110;i++)cout<<i<<":"<<seg::qry(i,N-3)<<endl;
  cin>>q;
  while(q--){
      ll t,i,x;
      cin>>t>>i>>x;
      if(t==1){
	  seg::upd(0,a[i],+1);
	  seg::upd(0,x,-1);
	  a[i]=x;
      }
      if(t==2){
	  seg::upd(0,b[i],-1);
	  seg::upd(0,x,+1);
	  b[i]=x;
      }
      //for(int i=0;i<110;i++)cout<<i<<":"<<seg::qry(i,N-3)<<endl;
      ll l=-1,r=N-3,mid;
      while(l<r-1){
	  mid=(l+r)>>1;
	  if(seg::qry(mid,N-3)<0)l=mid;
	  else r=mid;
      }
      printf("%lld\n",l);
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define LOCAL
#pragma region Macros
typedef long long ll;
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

template<typename Monoid,typename OperatorMonoid>
struct LazySegmentTree{
    typedef function<Monoid(Monoid,Monoid)> F;
    typedef function<Monoid(Monoid,OperatorMonoid)> G;
    typedef function<OperatorMonoid(OperatorMonoid,OperatorMonoid)> H;
    int n,hi;
    F f;
    G g;
    H h;
    Monoid id0;
    OperatorMonoid id1;
    vector<Monoid> dat;
    vector<OperatorMonoid> laz;
    LazySegmentTree(int n_,F f,G g,H h,Monoid id0,OperatorMonoid id1):
                    f(f),g(g),h(h),id0(id0),id1(id1){init(n_);}
    void init(int n_){
        n=1,hi=0;
        while(n<n_) n<<=1,++hi;
        dat.assign(n<<1,id0);
        laz.assign(n<<1,id1);
    }
    void build(const vector<Monoid> &v){
        for (int i=0;i<v.size();++i) dat[i+n]=v[i];
        for (int i=n-1;i;--i) dat[i]=f(dat[i<<1|0],dat[i<<1|1]);
    }
    inline Monoid reflect(int k){
        return laz[k]==id1?dat[k]:g(dat[k],laz[k]);
    }
    inline void propagate(int k){
        if (laz[k]==id1) return;
        laz[k<<1|0]=h(laz[k<<1|0],laz[k]);
        laz[k<<1|1]=h(laz[k<<1|1],laz[k]);
        dat[k]=reflect(k);
        laz[k]=id1;
    }
    inline void thrust(int k){
        for (int i=hi;i;--i) propagate(k>>i);
    }
    inline void recalc(int k){
        while(k>>=1) dat[k]=f(reflect(k<<1|0),reflect(k<<1|1));
    }
    void update(int a,int b,OperatorMonoid x){
        if (a>=b) return;
        thrust(a+=n),thrust(b+=n-1);
        for (int l=a,r=b+1;l<r;l>>=1,r>>=1){
            if (l&1) laz[l]=h(laz[l],x),++l;
            if (r&1) --r,laz[r]=h(laz[r],x);
        }
        recalc(a),recalc(b);
    }
    void set_val(int k,Monoid x){
        thrust(k+=n);
        dat[k]=x,laz[k]=id1;
        recalc(k);
    }
    Monoid query(int a,int b){
        if (a>=b) return id0;
        thrust(a+=n),thrust(b+=n-1);
        Monoid vl=id0,vr=id0;
        for (int l=a,r=b+1;l<r;l>>=1,r>>=1){
            if (l&1) vl=f(vl,reflect(l++));
            if (r&1) vr=f(reflect(--r),vr);
        }
        return f(vl,vr);
    }
    // most left position p that f[a...p] meets conditin "check"
    template<typename C>
    int find_first(int a,const C &check,Monoid &M,int k,int l,int r){
        if (l+1==r){
            M=f(M,reflect(k));
            return check(M)?k-n:-1;
        }
        propagate(k);
        int m=(l+r)>>1;
        if (m<=a) return find_first(a,check,M,k<<1|1,m,r);
        if (a<=l&&!check(f(M,dat[k]))){
            M=f(M,dat[k]);
            return -1;
        }
        int vl=find_first(a,check,M,k<<1|0,l,m);
        if (~vl) return vl;
        return find_first(a,check,M,k<<1|1,m,r);
    }
    template<typename C>
    int find_first(int a,const C &check){
        Monoid M=id0;
        return find_first(a,check,M,1,0,n);
    }
    // most right position p that f[p...b) meets condition "check"
    template<typename C>
    int find_last(int b,const C &check,Monoid &M,int k,int l,int r){
        if (l+1==r){
            M=f(reflect(k),M);
            return check(M)?k-n:-1;
        }
        propagate(k);
        int m=(l+r)>>1;
        if (b<=m) return find_last(b,check,M,k<<1|0,l,m);
        if (r<=b&&!check(f(dat[k],M))){
            M=f(dat[k],M);
            return -1;
        }
        int vr=find_last(b,check,M,k<<1|1,m,r);
        if (~vr) return vr;
        return find_last(b,check,M,k<<1|0,l,m);
    }
    template<typename C>
    int find_last(int b,const C &check){
        Monoid M=id0;
        return find_last(b,check,M,1,0,n);
    }
    Monoid operator[](int i){return query(i,i+1);}
};

const int MAX_A=1e6+10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    vector<int> a(n),b(m); cin >> a >> b;

    auto f=[](int a,int b){return min(a,b);};
    auto g=[](int a,int b){return a+b;};
    LazySegmentTree<int,int> seg(MAX_A,f,g,g,INF,0);
    vector<int> v(MAX_A,0);
    seg.build(v);
    for (int i=0;i<n;++i) seg.update(a[i],MAX_A,1);
    for (int i=0;i<m;++i) seg.update(b[i],MAX_A,-1);

    int q; cin >> q;
    for (;q--;){
        int t,i,x; cin >> t >> i >> x; --i;
        if (t==1){
            seg.update(a[i],MAX_A,-1);
            a[i]=x;
            seg.update(a[i],MAX_A,1);
        } else {
            seg.update(b[i],MAX_A,1);
            b[i]=x;
            seg.update(b[i],MAX_A,-1);
        }
        int ans=seg.find_last(MAX_A,[&](int x){return x<n-m;});
        cout << (ans<0?-1:ans+1) << '\n';
    }
}


#include <bits/stdc++.h>
using namespace std;

template<typename Monoid,typename OperatorMonoid>
struct LazySegmentTree{
    typedef function<Monoid(Monoid,Monoid)> F;
    typedef function<Monoid(Monoid,OperatorMonoid)> G;
    typedef function<OperatorMonoid(OperatorMonoid,OperatorMonoid)> H;
    int n,hi;
    F f;
    G g;
    H h;
    Monoid id0;
    OperatorMonoid id1;
    vector<Monoid> dat;
    vector<OperatorMonoid> laz;
    LazySegmentTree(int n_,F f,G g,H h,Monoid id0,OperatorMonoid id1):
                    f(f),g(g),h(h),id0(id0),id1(id1){init(n_);}
    void init(int n_){
        n=1,hi=0;
        while(n<n_) n<<=1,++hi;
        dat.assign(n<<1,id0);
        laz.assign(n<<1,id1);
    }
    void build(const vector<Monoid> &v){
        for (int i=0;i<v.size();++i) dat[i+n]=v[i];
        for (int i=n-1;i;--i) dat[i]=f(dat[i<<1|0],dat[i<<1|1]);
    }
    inline Monoid reflect(int k){
        return laz[k]==id1?dat[k]:g(dat[k],laz[k]);
    }
    inline void propagate(int k){
        if (laz[k]==id1) return;
        laz[k<<1|0]=h(laz[k<<1|0],laz[k]);
        laz[k<<1|1]=h(laz[k<<1|1],laz[k]);
        dat[k]=reflect(k);
        laz[k]=id1;
    }
    inline void thrust(int k){
        for (int i=hi;i;--i) propagate(k>>i);
    }
    inline void recalc(int k){
        while(k>>=1) dat[k]=f(reflect(k<<1|0),reflect(k<<1|1));
    }
    void update(int a,int b,OperatorMonoid x){
        if (a>=b) return;
        thrust(a+=n); thrust(b+=n-1);
        for (int l=a,r=b+1;l<r;l>>=1,r>>=1){
            if (l&1) laz[l]=h(laz[l],x),++l;
            if (r&1) --r,laz[r]=h(laz[r],x);
        }
        recalc(a); recalc(b);
    }
    void set_val(int k,Monoid x){
        thrust(k+=n);
        dat[k]=x,laz[k]=id1;
        recalc(k);
    }
    Monoid query(int a,int b){
        if (a>=b) return id0;
        thrust(a+=n); thrust(b+=n-1);
        Monoid vl=id0,vr=id0;
        for (int l=a,r=b+1;l<r;l>>=1,r>>=1){
            if (l&1) vl=f(vl,reflect(l++));
            if (r&1) vr=f(reflect(--r),vr);
        }
        return f(vl,vr);
    }
    template<typename C>
    int find_subtree(int k,const C &check,Monoid &M,bool type){
        while(k<n){
            propagate(k);
            Monoid nxt=type?f(reflect(k<<1|type),M):f(M,reflect(k<<1|type));
            if (check(nxt)) k=k<<1|type;
            else M=nxt,k=k<<1|(type^1);
        }
        return k-n;
    }
    // min i s.t. f(seg[a],seg[a+1],...,seg[i]) satisfy "check"
    template<typename C>
    int find_first(int a,const C &check){
        Monoid L=id0;
        if (a<=0){
            if (check(f(L,reflect(1)))) return find_subtree(1,check,L,false);
            return -1;
        }
        thrust(a+n);
        int b=n;
        for (int l=a+n,r=b+n;l<r;l>>=1,r>>=1){
            if (l&1){
                Monoid nxt=f(L,reflect(l));
                if (check(nxt)) return ffind_subtree(l,check,L,false);
                L=nxt; ++l;
            }
        }
        return -1;
    }
    // max i s.t. f(seg[i],...,seg[b-2],seg[b-1]) satisfy "check"
    template<typename C>
    int find_last(int b,const C &check){
        Monoid R=id0;
        if (b>=n){
            if (check(f(reflect(1),R))) return find_subtree(1,check,R,true);
            return -1;
        }
        thrust(b+n-1);
        int a=n;
        for (int l=a,r=b+n;l<r;l>>=1,r>>=1){
            if (r&1){
                Monoid nxt=f(reflect(--r),R);
                if (check(nxt)) return find_subtree(r,check,R,true);
                R=nxt;
            }
        }
        return -1;
    }
    Monoid operator[](int i){return query(i,i+1);}
};

// https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/all/DSL_2_D
// RUQ

void DSL_2_D(){
    int n,q; cin >> n >> q;
    auto f=[](int a,int b){return min(a,b);};
    auto g=[](int a,int b){return (~b?b:a);};
    auto h=[](int a,int b){return b;};
    LazySegmentTree<int,int> seg(n,f,g,h,INT_MAX,-1);
    for (;q--;){
        int c,s,t,x,i; cin >> c;
        if (!c){
            cin >> s >> t >> x;
            seg.update(s,t+1,x);
        } else {
            cin >> i;
            cout << seg[i] << '\n';
        }
    }
}

// https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/2/DSL_2_E
// RAQ

void DSL_2_E(){
    int n,q; cin >> n >> q;
    auto f=[](int a,int b){return a+b;};
    LazySegmentTree<int,int> seg(n,f,f,f,0,0);
    for (;q--;){
        int c,s,t,x,i; cin >> c;
        if (!c){
            cin >> s >> t >> x;
            seg.update(s-1,t,x);
        } else {
            cin >> i;
            cout << seg[i-1] << '\n';
        }
    }
}

// https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/2/DSL_2_F
// RMQ and RAQ

void DSL_2_F(){
    int n,q; cin >> n >> q;
    auto f=[](int a,int b){return min(a,b);};
    auto g=[](int a,int b){return (~b?b:a);};
    auto h=[](int a,int b){return b;};
    LazySegmentTree<int,int> seg(n,f,g,h,INT_MAX,-1);
    for (;q--;){
        int c,s,t,x; cin >> c >> s >> t;
        if (!c){
            cin >> x;
            seg.update(s,t+1,x);
        } else cout << seg.query(s,t+1) << '\n';
    }
}

// https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/2/DSL_2_G
// RSQ and RUQ

void DSL_2_G(){
    int n,q; cin >> n >> q;
    auto f=[](pair<long long,long long> a,pair<long long,long long> b){return make_pair(a.first+b.first,a.second+b.second);};
    auto g=[](pair<long long,long long> a,long long x){return make_pair(a.first+a.second*x,a.second);};
    auto h=[](long long a,long long b){return a+b;};
    LazySegmentTree<pair<long long,long long>,long long> seg(n,f,g,h,{0,0},0);
    vector<pair<long long,long long>> v(n,{0,1});
    seg.build(v);
    for (;q--;){
        int c,s,t,x; cin >> c >> s >> t;
        if (!c){
            cin >> x;
            seg.update(s-1,t,x);
        } else cout << seg.query(s-1,t).first << '\n';
    }
}

// https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/2/DSL_2_H
// RMQ and RAQ

void DSL_2_H(){
    int n,q; cin >> n >> q;
    auto f=[](int a,int b){return min(a,b);};
    auto g=[](int a,int b){return a+b;};
    LazySegmentTree<int,int> seg(n,f,g,g,INT_MAX,0);
    vector<int> v(n,0);
    seg.build(v);
    for (;q--;){
        int c,s,t,x; cin >> c >> s >> t;
        if (!c){
            cin >> x;
            seg.update(s,t+1,x);
        } else cout << seg.query(s,t+1) << '\n';
    }
}

// https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/2/DSL_2_I
// RSQ and RUQ

void DSL_2_I(){
    const int inf=1<<30;
    int n,q; cin >> n >> q;
    auto f=[](pair<long long,long long> a,pair<long long,long long> b){return make_pair(a.first+b.first,a.second+b.second);};
    auto g=[](pair<long long,long long> a,long long x){return make_pair(x!=inf?x*a.second:a.first,a.second);};
    auto h=[](long long a,long long b){return b;};
    LazySegmentTree<pair<long long,long long>,long long> seg(n,f,g,h,{0,0},inf);
    vector<pair<long long,long long>> v(n,{0,1});
    seg.build(v);
    for (;q--;){
        int c,s,t,x; cin >> c >> s >> t;
        if (!c){
            cin >> x;
            seg.update(s,t+1,x);
        } else cout << seg.query(s,t+1).first << '\n';
    }
}

// https://atcoder.jp/contests/abc177/tasks/abc177_f

void ABC177_F(){
    const int INF=1e9;
    int H,W; cin >> H >> W;
    vector<int> A(H),B(H);
    for (int i=0;i<H;++i) cin >> A[i] >> B[i],--A[i];

    auto f=[](int a,int b){return min(a,b);};
    auto g=[](int a,int x){return x!=-1?x:a;};
    auto h=[](int a,int b){return b;};
    LazySegmentTree<int,int> seg(W,f,g,h,INF,-1)
                            ,nseg(W,f,g,h,W,-1);
    vector<int> v(W,0);
    seg.build(v);
    iota(v.begin(),v.end(),0);
    nseg.build(v);

    for (int i=0;i<H;++i){
        int l=nseg.find_last(W,[&](int x){return x<A[i];})+1;
        int r=nseg.find_last(W,[&](int x){return x<B[i];});
        if (~r&&B[i]<W) seg.set_val(B[i],min(seg[B[i]],B[i]-r));
        nseg.update(l,r+1,B[i]);
        seg.update(A[i],B[i],INF);
        int ans=seg.query(0,W);
        cout << (ans==INF?-1:ans+i+1) << '\n';
    }
}

// https://codeforces.com/contest/1179/problem/C

void CFR569_C(){
    const int MAX_A=1e6+10,INF=1e9;
    int n,m; cin >> n >> m;
    vector<int> a(n),b(m);
    for (int i=0;i<n;++i) cin >> a[i];
    for (int i=0;i<m;++i) cin >> b[i];

    auto f=[](int a,int b){return min(a,b);};
    auto g=[](int a,int b){return a+b;};
    LazySegmentTree<int,int> seg(MAX_A,f,g,g,INF,0);
    vector<int> v(MAX_A,0);
    seg.build(v);
    for (int i=0;i<n;++i) seg.update(a[i],MAX_A,1);
    for (int i=0;i<m;++i) seg.update(b[i],MAX_A,-1);

    int q; cin >> q;
    for (;q--;){
        int t,i,x; cin >> t >> i >> x; --i;
        if (t==1){
            seg.update(a[i],MAX_A,-1);
            a[i]=x;
            seg.update(a[i],MAX_A,1);
        } else {
            seg.update(b[i],MAX_A,1);
            b[i]=x;
            seg.update(b[i],MAX_A,-1);
        }
        int ans=seg.find_last(MAX_A,[&](int x){return x<n-m;});
        cout << (ans<0?-1:ans+1) << '\n';
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    CFR569_C();
}