Codeforces Round #173 (Div. 2) XOR and Or

C. XOR and OR

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string. A Bitlandish string is a string made only of characters “0” and “1”. BitHaval (the mayor of Bitland) loves to play with Bitlandish strings. He takes some Bitlandish string a, and applies several (possibly zero) operations to it. In one operation the mayor may take any two adjacent characters of a string, define one of them as x and the other one as y. Then he calculates two values p and qp = x xor yq = x or y. Then he replaces one of the two taken characters by p and the other one by q. The xor operation means the bitwise excluding OR operation. The or operation is the bitwise OR operation. So for example one operation can transform string 11 to string 10 or to string 01. String 1 cannot be transformed into any other string. You’ve got two Bitlandish strings a and b. Your task is to check if it is possible for BitHaval to transform string a to string b in several (possibly zero) described operations.

Input

The first line contains Bitlandish string a, the second line contains Bitlandish string b. The strings can have different lengths. It is guaranteed that the given strings only consist of characters “0” and “1”. The strings are not empty, their length doesn’t exceed 106.

Output

Print “YES” if a can be transformed into b, otherwise print “NO”. Please do not print the quotes.

Sample test(s)

input

11 10


output

YES


input

1 01


output

NO


input

000 101


output

NO


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

int main()
{
char c;
int ones1=0,zero1=0,ones2=0,zero2=0;
int fs=1;
while(c=getchar())
{
if(1==fs)
{
if(c=='\n')fs=2;
else if(c=='1')ones1++;
else zero1++;
}
else
{
if(c=='\n')break;
else if(c=='1')ones2++;
else zero2++;
}
}
if(((ones2 && ones1) || ones2==ones1) && ones1+zero1==ones2+zero2)
cout<<"YES"<<endl;
else cout<<"NO"<<endl;
//system("pause");
return 0;
}