#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    	unsigned t;
        	cin >> t;
            	while (t--)
                	{
                    		unsigned long long a, b;
                            		cin >> a >> b;
                                    		if (b & 1)
                                            		{
                                                    			cout << -1;
                                                                			continue;
                                                                            		}
                                                                                    		for (unsigned long long i = ceil(sqrt(a)); i > 0; i--)
                                                                                            		{
                                                                                                    			unsigned long long j = i ^ b;
                                                                                                                			if (i*j == a)
                                                                                                                            			{
                                                                                                                                        				cout << i << ' ' << j << '\n';
                                                                                                                                                        				goto ok;
                                                                                                                                                                        			}
                                                                                                                                                                                    		}
                                                                                                                                                                                            		cout << -1;
                                                                                                                                                                                                    		ok: ;
                                                                                                                                                                                                            	}
                                                                                                                                                                                                                }