CF 1132 A Regular Bracket Sequence


time limit per test : 1 second
memory limit per test : 256 megabytes
input : standard input
output : standard output

Description

A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expression by inserting characters "+" and "1" into this sequence. For example, "", "(())" and "()()" are regular bracket sequences; "))" and ")((" are bracket sequences (but not regular ones), and "(a)" and "(1)+(1)" are not bracket sequences at all.

You have a number of strings; each string is a bracket sequence of length 2. So, overall you have cnt1 strings "((", cnt2 strings "()", cnt3 strings ")(" and cnt4 strings "))". You want to write all these strings in some order, one after another; after that, you will get a long bracket sequence of length 2(cnt1+cnt2+cnt3+cnt4). You wonder: is it possible to choose some order of the strings you have such that you will get a regular bracket sequence? Note that you may not remove any characters or strings, and you may not add anything either.

Input

The input consists of four lines, i-th of them contains one integer cnti (0≤cnti≤1e9).

Output

Print one integer: 1 if it is possible to form a regular bracket sequence by choosing the correct order of the given strings, 0 otherwise.

Example

input

3
1
4
3

output

1

input

1
2
3
4

output

0

Note

In the first example it is possible to construct a string "(())()(()((()()()())))", which is a regular bracket sequence.

In the second example it is possible to construct a string "", which is a regular bracket sequence.

Solution

  思路:

第二种无需考虑,其他三种只要第一种和第四种数量一样且不为0,同时第三种大于0即可。

#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

int main(){

    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a==d){
        if(c!=0){
            if(a==0) cout<<0;
            else cout<<1;
        }
        else cout<<1;
    }
    else cout<<0;
    return 0;
}