Language: C++

import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		
		while (true)
		{
			int n = sc.nextInt(),
				m = sc.nextInt();
			if (n == 0 && m == 0)
				break;
			
			int taro[] = new int[n];
			int taroTotal = 0;
			for (int i = 0; i < n; i++)
			{
				taro[i] = sc.nextInt();
				taroTotal += taro[i];
			}
			int hanako[] = new int[m];
			int hanakoTotal = 0;
			for (int i = 0; i < m; i++)
			{
				hanako[i] = sc.nextInt();
				hanakoTotal += hanako[i];
			}
			LOOP: {
				for (int i = 0; i < n; i++)
				{
					for (int j = 0; j < m; j++)
					{
						if (taroTotal - taro[i] + hanako[j] == hanakoTotal - hanako[j] + taro[i])
						{
							System.out.printf("%d %d\n", taro[i], hanako[j]);
							break LOOP;
						}
					}
				}
				System.out.println(-1);
			}
		}
	}
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.Scanner;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:15: error: expected ':' before 'static'
    5 |         public static void main(String args[])
      |               ^~~~~~~
      |               :
a.cc:5:33: error: 'String' has not been declared
    5 |         public static void main(String args[])
      |                                 ^~~~~~
a.cc:46:2: error: expected ';' after class definition
   46 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:7:17: error: 'Scanner' was not declared in this scope
    7 |                 Scanner sc = new Scanner(System.in);
      |                 ^~~~~~~
a.cc:11:33: error: 'sc' was not declared in this scope
   11 |                         int n = sc.nextInt(),
      |                                 ^~
a.cc:13:39: error: 'm' was not declared in this scope
   13 |                         if (n == 0 && m == 0)
      |                                       ^
a.cc:16:38: error: initializer fails to determine size of 'taro'
   16 |                         int taro[] = new int[n];
      |                                      ^~~~~~~~~~
a.cc:16:38: error: array must be initialized with a brace-enclosed initializer
a.cc:23:48: error: 'm' was not declared in this scope
   23 |                         int hanako[] = new int[m];
      |                                                ^
a.cc:23:40: error: initializer fails to determine size of 'hanako'
   23 |                         int hanako[] = new int[m];
      |                                        ^~~~~~~~~~
a.cc:23:40: error: array must be initialized with a brace-enclosed initializer
a.cc:37:57: error: 'System' was not declared in this scope
   37 |                                                         System.out.printf("%d %d\n", taro[i], hanako[j]);
      |                                                         ^~~~~~
a.cc:38:63: error: expected ';' before 'LOOP'
   38 |                                                         break LOOP;
      |                                                               ^~~~
a.cc:38:63: error: 'LOOP' was not declared in this scope
a.cc:42:33: error: 'System' was not declared in this scope
   42 |                                 System.out.println(-1);
      |                                 ^~~~~~