Grid game

You are given a 4x4 grid. You play a game — there is a sequence of tiles, each of them is either 2x1 or 1x2. Your task is to consequently place all tiles from the given sequence in the grid. When tile is placed, each cell which is located in fully occupied row or column is deleted (cells are deleted at the same time independently). You can place tile in the grid at any position, the only condition is that tiles (and tile parts) should not overlap. Your goal is to proceed all given figures and avoid crossing at any time.

Input

The only line contains a string ss consisting of zeroes and ones (1≤|s|≤10001≤|s|≤1000). Zero describes vertical tile, one describes horizontal tile.

Output

Output |s||s| lines — for each tile you should output two positive integers r,cr,c, not exceeding 44, representing numbers of smallest row and column intersecting with it.

If there exist multiple solutions, print any of them.

Example

Input

Copy

010

Output

Copy

1 1
1 2
1 4

Note

Following image illustrates the example after placing all three tiles:

Then the first row is deleted:

 

这题我以为暴力模拟,不会出冲突的,事实上会的。

正解看起来很简单,但是没想到:横的放(4,3),竖的放(1,1),然后,不管横竖怎么样,在左下角的那个位置一放就消,开心消消乐。

正解有很多种,只要构造出这种可以消掉的格式就行了。

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

string str;

int main()
{
//	freopen("input.in","r",stdin);
	bool heng=0,shu=0;
	cin>>str;
	int len=str.length();
	for(int i=0;i<len;i++)
	{
		if(str[i]=='0')
		{
			cout<<(shu?"3 1\n":"1 1\n");
			shu=!shu;
		}
		else
		{
			cout<<(heng?"4 1\n":"4 3\n");
			heng=!heng;
		}
	}
	return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值