output

standard output

You are given two segments [l1;r1][l1;r1] and [l2;r2][l2;r2] on the xx-axis. It is guaranteed that l1<r1l1<r1 and l2<r2l2<r2. Segments may intersect, overlap or even coincide with each other.

The example of two segments on the xx-axis.

Your problem is to find two integers aa and bb such that l1≤a≤r1l1≤a≤r1, l2≤b≤r2l2≤b≤r2 and a≠ba≠b. In other words, you have to choose two distinct integer points in such a way that the first point belongs to the segment [l1;r1][l1;r1] and the second one belongs to the segment [l2;r2][l2;r2].

It is guaranteed that the answer exists. If there are multiple answers, you can print any of them.

You have to answer qq independent queries.

Input

The first line of the input contains one integer qq (1≤q≤5001≤q≤500) — the number of queries.

Each of the next qq lines contains four integers l1i,r1i,l2il1i,r1i,l2i and r2ir2i (1≤l1i,r1i,l2i,r2i≤109,l1i<r1i,l2i<r2i1≤l1i,r1i,l2i,r2i≤109,l1i<r1i,l2i<r2i) — the ends of the segments in the ii-th query.

Output

Print 2q2q integers. For the ii-th query print two integers aiai and bibi — such numbers that l1i≤ai≤r1il1i≤ai≤r1i, l2i≤bi≤r2il2i≤bi≤r2i and ai≠biai≠bi. Queries are numbered in order of the input.

It is guaranteed that the answer exists. If there are multiple answers, you can print any.

Example

input

Copy

5
1 2 1 2
2 6 3 4
2 4 1 3
1 2 1 3
1 4 5 8

output

Copy

2 1
3 4
3 2
1 2
3 7

代码:

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm> using namespace std; int main()
{
int n;
cin>>n;
int l1,r1,l2,r2;
for(int t=0;t<n;t++)
{
scanf("%d%d%d%d",&l1,&r1,&l2,&r2);
int fi=l1;
int se;
for(int t=l2;t<=r2;t++)
{
if(t!=fi)
{
se=t;
break;
}
}
cout<<fi<<" "<<se<<endl;
} return 0;
}

最新文章

  1. ORA-00054: resource busy and acquire with NOWAIT specified
  2. C#中一些常用的正则表达式
  3. 多线程编程3 - GCD
  4. JVM参数调优
  5. (原创) cocos2dx使用Curl连接网络(客户端)
  6. 个人阅读作业 The Last
  7. 【转载】ASP.NET获取路径的方法
  8. 常用JDBC连接字符串
  9. OpenCV探索之路(十六):图像矫正技术深入探讨
  10. highcharts框架使用总结
  11. poj 1423 打表/斯特林公式
  12. 物理引擎中velocity的单位是个什么鬼?
  13. selenium自动化测试资源整理(含所有版本chrome、chromedriver、firefox下载链接)
  14. c语言之gdb调试。
  15. python 基本数据类型以及内置方法
  16. C++ 凸包生成算法
  17. 006、容器 What、Why、How(2018-12-21 周五)
  18. Xmpp获取离线消息
  19. Swift闭包(I) @autoclosure和@escaping的区别
  20. Eclipse提交代码到Spark集群上运行

热门文章

  1. awk简要使用
  2. hibernate学习笔记(2)持久化类测试
  3. android键盘的Done按钮
  4. JAVA基础知识总结13(同步)
  5. PAT-l3-002堆栈
  6. Codeforces 8C 状压DP
  7. Tensorflow学习—— AdamOptimizer
  8. HDOJ 1121 Complete the Sequence
  9. c#与Java事件定义的不同
  10. C++面试笔记--面向对象