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
5
1 2 1 2
2 6 3 4
2 4 1 3
1 2 1 3
1 4 5 8
Output
2 1
3 4
3 2
1 2
3 7 思路:给你两个区间,分别表示为[l1,r1] , [l2,r2]
让你输出两个不同的整数a和b,使之a属于第一个区间,b属于第二个区间。保证答案存在,注意a!=b
很签到的一题,注意下细节就好了。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=;while(b){if(b%)ans=ans*a%MOD;a=a*a%MOD;b/=;}return ans;}
inline void getInt(int* p);
const int maxn=;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int n; int main()
{
int l1,l2,r1,r2;
gg(n);
while(n--)
{
scanf("%d %d %d %d",&l1,&r1,&l2,&r2);
if(l1!=r2)
printf("%d %d\n",l1,r2 );
else
printf("%d %d\n",r1,l2 );
}
return ;
} inline void getInt(int* p) {
char ch;
do {
ch = getchar();
} while (ch == ' ' || ch == '\n');
if (ch == '-') {
*p = -(getchar() - '');
while ((ch = getchar()) >= '' && ch <= '') {
*p = *p * - ch + '';
}
}
else {
*p = ch - '';
while ((ch = getchar()) >= '' && ch <= '') {
*p = *p * + ch - '';
}
}
}

Two distinct points CodeForces - 1108A (签到)的更多相关文章

  1. Five Dimensional Points CodeForces - 851C (计算几何+暴力)

      C. Five Dimensional Points time limit per test 2 seconds memory limit per test 256 megabytes input ...

  2. Codeforce-A-Two distinct points(暴力)

    output standard output You are given two segments [l1;r1][l1;r1] and [l2;r2][l2;r2] on the xx-axis. ...

  3. B. Cover Points Codeforces Round #511 (Div. 2)【数学】

    题目: There are nn points on the plane, (x1,y1),(x2,y2),…,(xn,yn)(x1,y1),(x2,y2),…,(xn,yn). You need t ...

  4. CF1108A Two distinct points 题解

    Content 有 \(q\) 次询问,每次询问给定四个数 \(l_1,r_1,l_2,r_2\).对于每次询问,找到两个数 \(a,b\),使得 \(l_1\leqslant a\leqslant ...

  5. Codeforces Round #486 (Div. 3) D. Points and Powers of Two

    Codeforces Round #486 (Div. 3) D. Points and Powers of Two 题目连接: http://codeforces.com/group/T0ITBvo ...

  6. codeforces 872E. Points, Lines and Ready-made Titles

    http://codeforces.com/contest/872/problem/E E. Points, Lines and Ready-made Titles time limit per te ...

  7. Codeforces Round #245 (Div. 2) A. Points and Segments (easy) 贪心

    A. Points and Segments (easy) Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/con ...

  8. codeforces 251A Points on Line(二分or单调队列)

    Description Little Petya likes points a lot. Recently his mom has presented him n points lying on th ...

  9. Day8 - A - Points on Line CodeForces - 251A

    Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. N ...

随机推荐

  1. 洗礼灵魂,修炼python(75)--全栈项目实战篇(3)—— 账户注册登录管理系统

    要求: 1.系统可以创建用户和登录用户,根据用户的输入不同,做出不同的反应(创建还是登录) 2.创建用户不能创建已存在的用户名 3.登录用户的操作最多只能有三次,超过三次冻结账户,每使用一次提示用户还 ...

  2. 四、Tableau如何设置数据格式

    一.要求 ‘销售额’:K为单位 ‘利润’:        M为单位,负值用括号括起来,但是正值 ‘利润率’:带百分号,负值用括号括起来仍然时负值 二.解决方案 1.‘销售额’:m为单位 2.‘利润’: ...

  3. element-ui 2.4.8 BUG 标签页的最后一个Tab标题没法移除,更新后发现最新版本不存在该问题了 记录下

  4. eclipse版本对应名称以及下载地址

        Eclipse 1.0         2001年11月7日(Win32/Linux32 Motif) Eclipse 2.0         2002年6月27日(Linux32 Motif ...

  5. kafka_2.11-2.0.0_安装部署

    参考博文:kafka 配置文件参数详解 参考博文:Kafka[第一篇]Kafka集群搭建 参考博文:如何为Kafka集群选择合适的Partitions数量 参考博文:Kafka Server.prop ...

  6. Python-爬虫03:urllib.request模块的使用

    目录 1. urllib.request的基本使用 1.1 urlopen 1.2. 用urlopen来获取网络源代码 1.3. urllib.request.Request的使用 2. User-A ...

  7. elementUI el-input focus

    Q1. el-input 获取焦点 Q2. dialog中的 el-input获取焦点 Q3. dialog中有table table中有 el-input 要获取焦点 一个宗旨: this.$ref ...

  8. element ui Angular学习笔记(一)

    1.element ui安装 npm i --save element-angular 2.Angular-cli引入 引入后需要开启ElModule.forRoot(),也可以单独引入某个组件入El ...

  9. 在django中如何通过已有的mysql表生成django的model

    第一步:先是在项目中建立一个app:python manage.py startapp app01 第二步:python manage.py inspectdb > app01/models.p ...

  10. sqlite线程模式的设置

    (1)编译阶段 这几种模式可以通过参数SQLITE_THREADSAFE在编译阶段指定,可以取值0,1,2,默认是1.这三种取值的含义如下: 0:单线程模式,即内部不做mutex保护,多线程运行sql ...