```go
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
// The problem states string length can be up to 10^6.
// Default buffer size is 64KB, which is too small.
// We increase the buffer size to ~2MB to safely hold the input strings.
const maxCapacity = 2 * 1024 * 1024
buf := make([]byte, maxCapacity)
scanner.Buffer(buf, maxCapacity)
scanner.Split(bufio.ScanWords)
if !scanner.Scan() {
return
}
a := scanner.Text()
if !scanner.Scan() {
return
}
b := scanner.Text()
if len(a) != len(b) {
fmt.Println("NO")
return
}
// Logic:
// The operations allow transforming any string with at least one '1'
// into any other string of the same length with at least one '1'.
// A string of all '0's can only remain all '0's.
// Therefore, transformation is possible if and only if:
// 1. Lengths are equal.
// 2. Both strings contain a '1' OR both strings contain no '1's.
aHasOne := strings.Contains(a, "1")
bHasOne := strings.Contains(b, "1")
if aHasOne == bHasOne {
fmt.Println("YES")
} else {
fmt.Println("NO")
}
}
```