You are given $$$n$$$ strings $$$s_1, s_2, \dots, s_n$$$ of length at most $$$\mathbf{8}$$$. For each string $$$s_i$$$, determine if there exist two strings $$$s_j$$$ and $$$s_k$$$ such that $$$s_i = s_j + s_k$$$. That is, $$$s_i$$$ is the concatenation of $$$s_j$$$ and $$$s_k$$$. Note that $$$j$$$ can be equal to $$$k$$$.Recall that the concatenation of strings $$$s$$$ and $$$t$$$ is $$$s + t = s_1 s_2 \dots s_p t_1 t_2 \dots t_q$$$, where $$$p$$$ and $$$q$$$ are the lengths of strings $$$s$$$ and $$$t$$$ respectively. For example, concatenation of "code" and "forces" is "codeforces".

The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of strings. Then $$$n$$$ lines follow, the $$$i$$$-th of which contains non-empty string $$$s_i$$$ of length at most $$$\mathbf{8}$$$, consisting of lowercase English letters. Among the given $$$n$$$ strings, there may be equal (duplicates). The sum of $$$n$$$ over all test cases doesn't exceed $$$10^5$$$.

For each test case, output a binary string of length $$$n$$$. The $$$i$$$-th bit should be $$$\texttt{1}$$$ if there exist two strings $$$s_j$$$ and $$$s_k$$$ where $$$s_i = s_j + s_k$$$, and $$$\texttt{0}$$$ otherwise. Note that $$$j$$$ can be equal to $$$k$$$.

3

5

abab

ab

abc

abacb

c

3

x

xx

xxx

8

codeforc

es

codes

cod

forc

forces

e

code

NoteIn the first test case, we have the following:   $$$s_1 = s_2 + s_2$$$, since $$$\texttt{abab} = \texttt{ab} + \texttt{ab}$$$. Remember that $$$j$$$ can be equal to $$$k$$$.  $$$s_2$$$ is not the concatenation of any two strings in the list.  $$$s_3 = s_2 + s_5$$$, since $$$\texttt{abc} = \texttt{ab} + \texttt{c}$$$.  $$$s_4$$$ is not the concatenation of any two strings in the list.  $$$s_5$$$ is not the concatenation of any two strings in the list.  Since only $$$s_1$$$ and $$$s_3$$$ satisfy the conditions, only the first and third bits in the answer should be $$$\texttt{1}$$$, so the answer is $$$\texttt{10100}$$$.

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	in = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func Read[T any]() T{
	var i T
	fmt.Fscan(in, &i)
	return i
}

func ReadArray[T any](N int) []T{
	ans := make([]T, N)
	for i := 0; i < N; i++{
		ans[i] = Read[T]()
	}
	return ans
}

func Output[T any](val T) {
	fmt.Fprint(out, val)
}

func OutputN[T any](val T) {
	fmt.Fprintln(out, val)
}
func solve() {
	n := Read[int]()
	mp := map[string]bool{}

	arr := ReadArray[string](n)
	for i := 0; i < n; i++ {
		mp[arr[i]] = true
	}

	for i := 0; i < n; i++ {
		ln := len(arr[i])
		done := false
		for j := 0; j < ln; j++ {
			if _, ok := mp[arr[i][0:j]]; ok {
				if _, ok := mp[arr[i][j:ln]]; ok {
					done = true
					break
				}
			}
		}
		if done {
			Output[int32](1)
		} else {
			Output[int32](0)
		}
	}
	fmt.Fprintln(out)

}
func main(){
	defer out.Flush()
	tt := 1
	tt = Read[int]()
	for tt > 0 {
		solve()
		tt--
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	in = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func Read[T any]() T{
	var i T
	fmt.Fscan(in, &i)
	return i
}

func ReadArray[T any](N int) []T{
	ans := make([]T, N)
	for i := 0; i < N; i++{
		ans[i] = Read[T]()
	}
	return ans
}

func solve() {
	n := Read[int]()
	mp := map[string]bool{}

	arr := ReadArray[string](n)
	for i := 0; i < n; i++ {
		mp[arr[i]] = true
	}

	for i := 0; i < n; i++ {
		ln := len(arr[i])
		done := false
		for j := 0; j < ln; j++ {
			if _, ok := mp[arr[i][0:j]]; ok {
				if _, ok := mp[arr[i][j:ln]]; ok {
					done = true
					break
				}
			}
		}
		if done {
			fmt.Fprint(out, 1)
		} else {
			fmt.Fprint(out, 0)
		}
	}
	fmt.Fprintln(out)

}
func main(){
	defer out.Flush()
	tt := 1
	tt = Read[int]()
	for tt > 0 {
		solve()
		tt--
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	in = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func Read[T any]() T{
	var i T
	fmt.Fscan(in, &i)
	return i
}

func ReadArray[T any](N int) []T{
	ans := make([]T, N)
	for i := 0; i < N; i++{
		ans[i] = Read[T]()
	}
	return ans
}

func solve() {
	n := Read[int]()
	mp := map[string]bool{}

	arr := ReadArray[string](n)
	ans := []bool{}
	for i := 0; i < n; i++ {
		mp[arr[i]] = true
	}

	for i := 0; i < n; i++ {
		ln := len(arr[i])
		done := false
		for j := 0; j < ln; j++ {
			if _, ok := mp[arr[i][0:j]]; ok {
				if _, ok := mp[arr[i][j:ln]]; ok {
					ans = append(ans, true)
					done = true
					break
				}
			}
		}
		if !done {
			ans = append(ans, false)
		}
	}
	for i := 0; i < n; i++ {
		if ans[i] {
			fmt.Fprint(out, 1)
		} else {
			fmt.Fprint(out, 0)
		}
	}
	fmt.Fprintln(out)

}
func main(){
	defer out.Flush()
	tt := 1
	tt = Read[int]()
	for tt > 0 {
		solve()
		tt--
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	in = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func Read[T any]() T{
	var i T
	fmt.Fscan(in, &i)
	return i
}

func ReadArray[T any](N int) []T{
	ans := make([]T, N)
	for i := 0; i < N; i++{
		ans[i] = Read[T]()
	}
	return ans
}

func solve() {
	n := Read[int]()
	mp := map[string]bool{}

	arr := ReadArray[string](n)
	ans := []bool{}
	for i := 0; i < n; i++ {
		mp[arr[i]] = true
	}

	for i := 0; i < n; i++ {
		ln := len(arr[i])
		done := false
		for j := 0; j < ln; j++ {
			if _, ok := mp[arr[i][0:j]]; ok {
				if _, ok := mp[arr[i][j:ln]]; ok {
					ans = append(ans, true)
					done = true
					break
				}
			}
		}
		if !done {
			ans = append(ans, false)
		}
	}
	for i := 0; i < n; i++ {
		if ans[i] {
			fmt.Print(1)
		} else {
			fmt.Print(0)
		}
	}
	fmt.Println()

}
func main(){
	defer out.Flush()
	tt := 1
	tt = Read[int]()
	for tt > 0 {
		solve()
		tt--
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	in = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func Read[T any]() T{
	var i T
	fmt.Fscan(in, &i)
	return i
}

func ReadArray[T any](N int) []T{
	ans := make([]T, N)
	for i := 0; i < N; i++{
		ans[i] = Read[T]()
	}
	return ans
}

const N int = 1e5
var arr = [N]string{}
var ans = [N]bool{}

func solve() {
	n := Read[int]()

	mp := map[string]bool{}

	for i := 0; i < n; i++ {
		arr[i] = Read[string]()
		mp[arr[i]] = true
		ans[i] = false
	}

	for i := 0; i < n; i++ {
		ln := len(arr[i])
		for j := 0; j < ln; j++ {
			if _, ok := mp[arr[i][0:j]]; ok {
				if _, ok := mp[arr[i][j:ln]]; ok {
					ans[i] = true
				}
			}
		}
	}
	for i := 0; i < n; i++ {
		if ans[i] {
			fmt.Print(1)
		} else {
			fmt.Print(0)
		}
	}
	fmt.Println()

}
func main(){
	defer out.Flush()
	tt := 1
	tt = Read[int]()
	for tt > 0 {
		solve()
		tt--
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func doubleStrings(strs []string) []int {
	stringsMap := make(map[string]bool)
	for _, str := range strs {
		stringsMap[str] = true
	}
	results := make([]int, len(strs))
	for i, str := range strs {
		for j := 0; j < len(str); j++ {
			str1 := str[0 : j+1]
			str2 := str[j+1 : len(str)]
			if stringsMap[str1] && stringsMap[str2] {
				results[i] = 1
			}
		}
	}
	return results
}

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 16*1024*1024)
	T, err := strconv.Atoi(strings.TrimSpace(readLine(reader)))
	checkError(err)
	var results = make([][]int, T)
	for i := 0; i < T; i++ {
		N, err := strconv.Atoi(strings.TrimSpace(readLine(reader)))
		checkError(err)
		strs := make([]string, N)
		for i := 0; i < N; i++ {
			strs[i] = strings.TrimSpace(readLine(reader))
		}
		results[i] = doubleStrings(strs)
	}
	for _, result := range results {
		for _, r := range result {
			fmt.Print(r)
		}
		fmt.Println()
	}
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err != nil {
		return ""
	}
	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func ReadInt() int{
	var i int
	fmt.Fscan(in, &i)
	return i
}

func ReadIntArray(N int) []int{
	ans := make([]int, N)
	for i := 0; i < N; i++{
		fmt.Fscan(in, &ans[i])
	}
	return ans
}

func ReadString() string{
	var s string
	fmt.Scanf("%s", &s)
	return s
}

func ReadStringArray(N int) []string{
	ans := make([]string, N)
	for i := 0; i < N; i++{
		fmt.Fscan(in, &ans[i])
	}
	return ans
}

func main(){
	defer out.Flush()
	testCases := ReadInt()
	for ; testCases > 0; testCases--{
		N := ReadInt()
		SS := ReadStringArray(N)
		cache := make(map[string]bool)
		for i := 0; i < N; i++{
			cache[SS[i]] = true
		}
		for i := 0; i < N; i++{
			found := false
			for j := 0; j < len(SS[i]) - 1; j++{
				_, left := cache[SS[i][:j+1]]
				_, right := cache[SS[i][j+1:len(SS[i])]]
				if left && right {
					found = true
					break
				}
			}
			if found{
				fmt.Fprint(out, 1)
			} else{
				fmt.Fprint(out, 0)
			}
		}
		fmt.Fprintln(out)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type CF1703D struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1703D) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1703D) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1703D) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1703D) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1703D) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1703D
Date: 25/07/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1703/D
Problem: CF1703D
**/
func (in *CF1703D) Run() {
	var sol strings.Builder
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		mapa := make(map[string][]int)

		for i := 0; i < n; i++ {
			str := in.NextString()
			if _, e := mapa[str]; !e {
				a := make([]int, 0)
				mapa[str] = a
			}
			arr := mapa[str]
			arr = append(arr, i)
			mapa[str] = arr
		}

		ans := make([]int, n)
		for s, val := range mapa {
			ws := false
			for j := 1; j < len(s); j++ {
				if _, e := mapa[s[0:j]]; e {
					if _, e := mapa[s[j:]]; e {
						ws = true
						break
					}
				}
			}
			for p := 0; p < len(val); p++ {
				if ws {
					ans[val[p]] = 1
				} else {
					ans[val[p]] = 0
				}

			}
		}

		for i := 0; i < n; i++ {
			sol.WriteString(fmt.Sprintf("%d", ans[i]))
		}
		sol.WriteString("\n")
	}
	fmt.Print(sol.String())
}

func NewCF1703D(r *bufio.Reader) *CF1703D {
	return &CF1703D{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1703D(bufio.NewReader(os.Stdin)).Run()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type CF1703D struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1703D) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1703D) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1703D) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1703D) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1703D) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1703D
Date: 25/07/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1703/D
Problem: CF1703D
**/
func (in *CF1703D) Run() {
	var sol strings.Builder
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		mapa := make(map[string][]int)

		for i := 0; i < n; i++ {
			str := in.NextString()
			if _, e := mapa[str]; !e {
				a := make([]int, 0)
				mapa[str] = a
			}
			arr := mapa[str]
			arr = append(arr, i)
			mapa[str] = arr
		}

		ans := make([]int, n)
		for i := 0; i < n; i++ {
			ans[i] = -1
		}
		for s, val := range mapa {
			if ans[val[0]] == 1 || ans[val[0]] == 0 {
				continue
			}
			ws := false
			for j := 1; j < len(s); j++ {
				if _, e := mapa[s[0:j]]; e {
					if _, e := mapa[s[j:]]; e {
						ws = true
						break
					}
				}
			}
			for p := 0; p < len(val); p++ {
				if ws {
					ans[val[p]] = 1
				} else {
					ans[val[p]] = 0
				}

			}
		}

		for i := 0; i < n; i++ {
			sol.WriteString(fmt.Sprintf("%d", ans[i]))
		}
		sol.WriteString("\n")
	}
	fmt.Print(sol.String())
}

func NewCF1703D(r *bufio.Reader) *CF1703D {
	return &CF1703D{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1703D(bufio.NewReader(os.Stdin)).Run()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

type CF1703D struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1703D) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1703D) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1703D) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1703D) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1703D) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1703D
Date: 25/07/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1703/D
Problem: CF1703D
**/
func (in *CF1703D) Run() {
	var sol strings.Builder
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		mapa := make(map[string][]int)

		s := make([]string, n)
		for i := 0; i < n; i++ {
			str := in.NextString()
			s[i] = str
			if _, e := mapa[str]; !e {
				a := make([]int, 0)
				mapa[str] = a
			}
			arr := mapa[str]
			arr = append(arr, i)
			mapa[str] = arr
		}

		sort.Slice(s, func(i, j int) bool {
			if len(s[i]) < len(s[j]) {
				return true
			} else if len(s[i]) > len(s[j]) {
				return false
			} else {
				return s[i] < s[j]
			}
		})

		ans := make([]int, n)
		for i := 0; i < n; i++ {
			ans[i] = -1
		}
		for i := n - 1; i >= 0; i-- {
			val := mapa[s[i]]
			if ans[val[0]] == 1 || ans[val[0]] == 0 {
				continue
			}
			ws := false
			for j := 1; j < len(s[i]); j++ {
				if _, e := mapa[s[i][0:j]]; e {
					if _, e := mapa[s[i][j:]]; e {
						ws = true
						break
					}
				}
			}

			for p := 0; p < len(val); p++ {
				if ws {
					ans[val[p]] = 1
				} else {
					ans[val[p]] = 0
				}

			}
		}

		for i := 0; i < n; i++ {
			sol.WriteString(fmt.Sprintf("%d", ans[i]))
		}
		sol.WriteString("\n")
	}
	fmt.Print(sol.String())
}

func NewCF1703D(r *bufio.Reader) *CF1703D {
	return &CF1703D{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1703D(bufio.NewReader(os.Stdin)).Run()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)

		aa := make([]string, n)
		m := make(map[string]bool, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
			m[aa[i]] = true
		}

		buf := make([]rune, n)
		for i, s := range aa {
			var f bool
			for i := 1; i < len(s); i++ {
				if m[s[:i]] && m[s[i:]] {
					f = true
					break
				}
			}
			if f {
				buf[i] = '1'
			} else {
				buf[i] = '0'
			}
		}
		fmt.Fprintln(out, string(buf))
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

const mod = 998244353
const mx = int64(1e9 + 7)

func solve(in *bufio.Reader, out *bufio.Writer) {
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)
	arr := make([]string, n)
	mp := map[string]bool{}
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &arr[i])
		mp[arr[i]] = true
	}
	ans := make([]byte, n)
	for i := 0; i < n; i++ {
		valid := false
		for j := 0; j < len(arr[i])-1; j++ {
			if mp[arr[i][:j+1]] && mp[arr[i][j+1:]] {
				valid = true
				break
			}
		}
		if valid {
			ans[i] = '1'
		} else {
			ans[i] = '0'
		}
	}
	fmt.Fprintln(out, string(ans))
}

func abs(a int64) int64 {
	if a > 0 {
		return a
	}
	return -a
}
func sum(a, b int64) int64 {
	return (b + a) * (b - a + 1) / 2
}

func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
func min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func gcd(a, b int) int {
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

func main() {
	stdin := os.Stdin
	stdout := os.Stdout
	in := bufio.NewReader(stdin)
	out := bufio.NewWriter(stdout)
	n := 1
	fmt.Fscan(in, &n)
	for i := 0; i < n; i++ {
		solve(in, out)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var rr = bufio.NewReader(os.Stdin)
var ww = bufio.NewWriter(os.Stdout)

type trieNode struct {
	children	[26]*trieNode
	isEnd		bool
}

func (o *trieNode) empty() bool {
	for _, child := range o.children {
		if child != nil {
			return false
		}
	}
	return true
}

type trie struct {
	root *trieNode
}

func newTrie() *trie {
	return &trie{&trieNode{}}
}

func ord(c byte) byte {
	return c - 'a'
}

func chr(v byte) byte {
	return v + 'a'
}

func (t *trie) put(s []byte) *trieNode {
	o := t.root
	for _, b := range s {
		b = ord(b)
		if o.children[b] == nil {
			o.children[b] = &trieNode{}
		}
		o = o.children[b]
	}
	o.isEnd = true
	return o
}

func (t *trie) find(s []byte) *trieNode {
	o := t.root
	for _, b := range s {
		o = o.children[ord(b)]
		// 未找到 s，且 s 不是任何字符串的前缀
		if o == nil {
			return nil
		}
	}
	// 未找到 s，但是 s 是某个字符串的前缀
	if !o.isEnd {
		return nil
	}
	return o
}

func (t *trie) find1(s []byte) bool {
	o := t.root
	for i, b := range s {
		o = o.children[ord(b)]
		if o.isEnd && t.find(s[i+1:]) != nil {
			return true
		}
	}
	// 未找到 s，但是 s 是某个字符串的前缀
	return false
}

func (t *trie) delete(s []byte) *trieNode {
	fa := make([]*trieNode, len(s))
	o := t.root
	for i, b := range s {
		fa[i] = o
		o = o.children[ord(b)]
		if o == nil {
			return nil
		}
	}
	if !o.isEnd {
		return nil
	}
	o.isEnd = false
	ret := o
	for i := len(s) - 1; i >= 0; i-- {
		if !o.empty() {
			break
		}
		o = fa[i]
		o.children[ord(s[i])] = nil
	}
	return ret
}

func slove() {
	var n int
	t := newTrie()
	fmt.Fscan(rr, &n)
	ss := make([]string, n)

	for i:=0;i<n;i++ {
		var a string
		fmt.Fscan(rr, &a)
		t.put([]byte(a))
		ss[i] = a
	}
	ans := make([]byte, n)
	for i := range ss {
		if t.find1([]byte(ss[i])) {
			ans[i] = '1'
		} else {
			ans[i] = '0'
		}
	}
	fmt.Fprintln(ww, string(ans))
}

func main() {
	defer ww.Flush()
	var n int
	fmt.Fscan(rr, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

package main

import (
	"bufio"
	. "fmt"
	"os"
)

func main() {
	r, w := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer w.Flush()
	var t, n int
	Fscan(r, &t)
	for t > 0{
		t--
		Fscan(r, &n)
		b := make([]byte, n)
		m := make(map[string]int)
		a := make([]string, n)
		for i := range a{
			Fscan(r, &a[i])
			m[a[i]] = 1
		}
		for i := range a{
			b[i] = '0'
			for j := 1; j < len(a[i]); j++{
				if m[a[i][0:j]] == 1 && m[a[i][j:]] == 1{
					b[i] = '1'
					break
				}
			}
		}
		Fprintln(w, string(b))
	}
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
	"sort"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	var buf bytes.Buffer

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		S := make([]string, n)
		for i := 0; i < n; i++ {
			S[i] = readString(reader)
		}
		res := solve(S)
		buf.WriteString(res)
		buf.WriteByte('\n')
	}

	fmt.Print(buf.String())
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(s []string) string {
	n := len(s)
	ii := make([]int, n)
	for i := 0; i < n; i++ {
		ii[i] = i
	}

	sort.Slice(ii, func(i, j int) bool {
		return len(s[ii[i]]) < len(s[ii[j]])
	})

	mem := make(map[string]bool)

	res := make([]byte, n)

	for i := 0; i < n; i++ {
		j := ii[i]
		res[j] = '0'
		for k := 1; k+1 <= len(s[j]); k++ {
			x := s[j][:k]
			y := s[j][k:]
			if mem[x] && mem[y] {
				res[j] = '1'
				break
			}
		}
		mem[s[j]] = true
	}

	return string(res)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var (
	reader  = bufio.NewReader(os.Stdin)
	t, n, x int
	a       []string
)

func solve(n int, a []string) string {
	var strMapper = make(map[string]bool)
	for _, x := range a {
		strMapper[x] = true
	}
	var result = make([]int, n)
	for i := 0; i < n; i++ {
		for j := 0; j < len(a[i]); j++ {
			if strMapper[a[i][:j]] && strMapper[a[i][j:]] {
				result[i] = 1
				break
			}
		}
	}
	return strings.Trim(strings.Replace(fmt.Sprint(result), " ", "", -1), "[]")
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		a = make([]string, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		fmt.Println(solve(n, a))
	}
}

package main

import (
	"bufio"
	"bytes"
	. "fmt"
	"io"
	"os"
	"sort"
)

// https://space.bilibili.com/206214
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, n int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		type pair struct{ s string; i int }
		a := make([]pair, n)
		for i := range a {
			Fscan(in, &a[i].s)
			a[i].i = i
		}
		sort.Slice(a, func(i, j int) bool { return len(a[i].s) < len(a[j].s) })
		cnt := map[string]int{}
		ans := bytes.Repeat([]byte{'0'}, n)
		for _, p := range a {
			for i := 1; i < len(p.s); i++ {
				if c1,c2 := cnt[p.s[:i]],cnt[p.s[i:]];c1>0 && c2 > 0 {
					ans[p.i] = '1'
				}
			}
			cnt[p.s]++
		}
		Fprintf(out, "%s\n", ans)
	}
}

func main() { run(os.Stdin, os.Stdout) }

// 1703D. Double Strings
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n int
		fmt.Fscan(reader, &n)
		a := make([]string, n)
		m := make(map[string]bool)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
			m[a[i]] = true
		}
		ans := make([]string, n)
		for i := 0; i < n; i++ {
			exists := false
			for j := 1; j < len(a[i]); j++ {
				if m[a[i][:j]] && m[a[i][j:]] {
					exists = true
					break
				}
			}
			if exists {
				ans[i] = "1"
			} else {
				ans[i] = "0"
			}
		}
		fmt.Println(strings.Join(ans, ""))
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

var _, _, _ = main, rw, do

func main() {
	r, w := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer w.Flush()
	rw(r, w)
}

func rw(r io.Reader, w io.Writer) {
	var t int
	fmt.Fscan(r, &t)
	for ti := 0; ti < t; ti++ {
		var n int
		fmt.Fscan(r, &n)
		b := make([]string, n)
		for i := range b {
			fmt.Fscan(r, &b[i])
		}
		w1 := do(b)
		fmt.Fprintln(w, w1)
	}
}

func do(b []string) string {
	m := make(map[string]bool)
	for _, s := range b {
		m[s] = true
	}
	ans := make([]byte, len(b))
	for j, s := range b {
		ans[j] = '0'
		for i := 1; i < len(s); i++ {
			if m[s[:i]] && m[s[i:]] {
				ans[j] = '1'
				break
			}
		}
	}
	return string(ans)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	in = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func Read[T any]() T{
	var i T
	fmt.Fscan(in, &i)
	return i
}

func ReadArray[T any](N int) []T{
	ans := make([]T, N)
	for i := 0; i < N; i++{
		ans[i] = Read[T]()
	}
	return ans
}

func solve() {
	n := Read[int]()
	mp := map[string]bool{}

	arr := ReadArray[string](n)
	ans := []bool{}
	for i := 0; i < n; i++ {
		mp[arr[i]] = true
	}

	for i := 0; i < n; i++ {
		ln := len(arr[i])
		done := false
		for j := 0; j < ln; j++ {
			if _, ok := mp[arr[i][0:j]]; ok {
				if _, ok := mp[arr[i][j:ln]]; ok {
					ans = append(ans, true)
					done = true
					break
				}
			}
		}
		if !done {
			ans = append(ans, false)
		}
	}
	for i := 0; i < n; i++ {
		if ans[i] {
			fmt.Fprint(out, 1)
		} else {
			fmt.Fprint(out, 0)
		}
	}
	fmt.Fprint(out)

}
func main(){
	defer out.Flush()
	tt := 1
	tt = Read[int]()
	for tt > 0 {
		solve()
		tt--
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func doubleStrings(strs []string) []int {
	stringsMap := make(map[string][]int)
	results := make([]int, len(strs))
	for i, str := range strs {
		if _, ok := stringsMap[str]; ok {
			stringsMap[str] = append(stringsMap[str], i)
		} else {
			stringsMap[str] = []int{i}
		}
	}
	for i := 0; i < len(strs); i++ {
		for j := 0; j < len(strs); j++ {
			if len(strs[i])+len(strs[j]) > 8 {
				continue
			}
			str := strs[i] + strs[j]
			if _, ok := stringsMap[str]; ok {
				for _, k := range stringsMap[str] {
					results[k] = 1
				}
				break
			}
		}
	}
	return results
}

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 16*1024*1024)
	T, err := strconv.Atoi(strings.TrimSpace(readLine(reader)))
	checkError(err)
	var results = make([][]int, T)
	for i := 0; i < T; i++ {
		N, err := strconv.Atoi(strings.TrimSpace(readLine(reader)))
		checkError(err)
		strs := make([]string, N)
		for i := 0; i < N; i++ {
			strs[i] = strings.TrimSpace(readLine(reader))
		}
		results[i] = doubleStrings(strs)
	}
	for _, result := range results {
		for _, r := range result {
			fmt.Print(r)
		}
		fmt.Println()
	}
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err != nil {
		return ""
	}
	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func doubleStrings(strs []string) []int {
	stringsMap := make(map[string]int)
	results := make([]int, len(strs))
	for i, str := range strs {
		stringsMap[str] = i
	}
	for i := 0; i < len(strs); i++ {
		for j := 0; j < len(strs); j++ {
			if len(strs[i])+len(strs[j]) > 8 {
				continue
			}
			str := strs[i] + strs[j]
			if k, ok := stringsMap[str]; ok {
				results[k] = 1
			}
		}
	}
	return results
}

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 16*1024*1024)
	T, err := strconv.Atoi(strings.TrimSpace(readLine(reader)))
	checkError(err)
	var results = make([][]int, T)
	for i := 0; i < T; i++ {
		N, err := strconv.Atoi(strings.TrimSpace(readLine(reader)))
		checkError(err)
		strs := make([]string, N)
		for i := 0; i < N; i++ {
			strs[i] = strings.TrimSpace(readLine(reader))
		}
		results[i] = doubleStrings(strs)
	}
	for _, result := range results {
		for _, r := range result {
			fmt.Print(r)
		}
		fmt.Println()
	}
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err != nil {
		return ""
	}
	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func doubleStrings(strs []string) []int {
	stringsMap := make(map[string]int)
	results := make([]int, len(strs))
	for i, str := range strs {
		stringsMap[str] = i
	}
	// for i := 0; i < len(strs); i++ {
	for j := 0; j < len(strs); j++ {
		for k := 0; k < len(strs); k++ {
			str := strs[j] + strs[k]
			// str2 := strs[k] + strs[j]
			if i, ok := stringsMap[str]; ok {
				results[i] = 1
			}
		}
	}
	// }
	return results
}

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 16*1024*1024)
	T, err := strconv.Atoi(strings.TrimSpace(readLine(reader)))
	checkError(err)
	var results = make([][]int, T)
	for i := 0; i < T; i++ {
		N, err := strconv.Atoi(strings.TrimSpace(readLine(reader)))
		checkError(err)
		strs := make([]string, N)
		for i := 0; i < N; i++ {
			strs[i] = strings.TrimSpace(readLine(reader))
		}
		results[i] = doubleStrings(strs)
	}
	for _, result := range results {
		for _, r := range result {
			fmt.Print(r)
		}
		fmt.Println()
	}
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err != nil {
		return ""
	}
	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

package main

import (
	"fmt"
)

func ReadInt() int{
	var i int
	fmt.Scanf("%d", &i)
	return i
}

func ReadIntArray(N int) []int{
	ans := make([]int, N)
	for i := 0; i < N; i++{
		ans[i] = ReadInt()
	}
	return ans
}

func ReadString() string{
	var s string
	fmt.Scanf("%s", &s)
	return s
}

func ReadStringArray(N int) []string{
	ans := make([]string, N)
	for i := 0; i < N; i++{
		if i < N-1{
			fmt.Scanf("%s ", &ans[i])
		} else{
			fmt.Scanf("%s\n", &ans[i])
		}
	}
	return ans
}

func main(){
	testCases := ReadInt()
	for ; testCases > 0; testCases--{
		N := ReadInt()
		SS := ReadStringArray(N)
		cache := make(map[string]bool)
		for i := 0; i < N; i++{
			cache[SS[i]] = true
		}
		for i := 0; i < N; i++{
			found := false
			for j := 0; j < len(SS[i]) - 1; j++{
				_, left := cache[SS[i][:j+1]]
				_, right := cache[SS[i][j+1:len(SS[i])]]
				if left && right {
					found = true
					break
				}
			}
			if found{
				fmt.Print(1)
			} else{
				fmt.Print(0)
			}
		}
		fmt.Println()
	}
}

package main

import (
	"fmt"
)

func ReadInt() int{
	var i int
	fmt.Scanf("%d", &i)
	return i
}

func ReadIntArray(N int) []int{
	ans := make([]int, N)
	for i := 0; i < N; i++{
		ans[i] = ReadInt()
	}
	return ans
}

func ReadString() string{
	var s string
	fmt.Scanf("%s", &s)
	return s
}

func ReadStringArray(N int) []string{
	ans := make([]string, N)
	for i := 0; i < N; i++{
		ans[i] = ReadString()
	}
	return ans
}

func main(){
	testCases := ReadInt()
	for ; testCases > 0; testCases--{
		N := ReadInt()
		SS := ReadStringArray(N)
		cache := make(map[string]bool)
		for i := 0; i < N; i++{
			cache[SS[i]] = true
		}
		for i := 0; i < N; i++{
			found := false
			for j := 0; j < len(SS[i]) - 1; j++{
				_, left := cache[SS[i][:j+1]]
				_, right := cache[SS[i][j+1:len(SS[i])]]
				if left && right {
					found = true
					break
				}
			}
			if found{
				fmt.Print(1)
			} else{
				fmt.Print(0)
			}
		}
		fmt.Println()
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

const mod = 998244353
const mx = int64(1e9 + 7)

func solve(in *bufio.Reader, out *bufio.Writer) {
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)
	arr := make([]string, n)
	mp := map[string]bool{}
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &arr[i])
		mp[arr[i]] = true
	}
	ans := make([]byte, n)
	for i := 0; i < n; i++ {
		valid := false
		for j := 0; j < len(arr[i])-1; j++ {
			if mp[arr[i][:j+1]] && mp[arr[i][j+1:]] {
				valid = true
				break
			}
		}
		if valid {
			ans[i] = '1'
		} else {
			ans[i] = '0'
		}
	}
	fmt.Fprintln(out, string(ans))
}

func abs(a int64) int64 {
	if a > 0 {
		return a
	}
	return -a
}
func sum(a, b int64) int64 {
	return (b + a) * (b - a + 1) / 2
}

func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
func min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func gcd(a, b int) int {
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

func main() {
	fmt.Println("01234"[3:])
	stdin := os.Stdin
	stdout := os.Stdout
	in := bufio.NewReader(stdin)
	out := bufio.NewWriter(stdout)
	n := 1
	fmt.Fscan(in, &n)
	for i := 0; i < n; i++ {
		solve(in, out)
	}
}


In the beginning of the new year Keivan decided to reverse his name. He doesn't like palindromes, so he changed Naviek to Navick.He is too selfish, so for a given n he wants to obtain a string of n characters, each of which is either 'a', 'b' or 'c', with no palindromes of length 3 appearing in the string as a substring. For example, the strings "abc" and "abca" suit him, while the string "aba" doesn't. He also want the number of letters 'c' in his string to be as little as possible.

The first line contains single integer n (1 ≤ n ≤ 2·105) — the length of the string.

Print the string that satisfies all the constraints. If there are multiple answers, print any of them.

NoteA palindrome is a sequence of characters which reads the same backward and forward.

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	if n == 1 {
		fmt.Println("a")
		return
	}
	if n >= 3 && n % 2 == 1 {
		fmt.Print("b")
		n--
	}
	for i:=0;i<n/2;i++ {
		if i % 2 == 0 {
			fmt.Print("aa")
		} else {
			fmt.Print("bb")
		}
	}

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func I(i ...interface{}) error {
	_, err := fmt.Fscan(r, i...)
	return err
}

func O(o ...interface{}) {
	fmt.Fprint(w, o...)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.goC"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	var n int
	for I(&n) == nil {
		solve(n)
	}
	w.Flush()
}

func solve(n int) {
	ans := strings.Repeat("aabb", (n/4)+10)
	O(ans[:n], "\n")
}

package main

import (
	"fmt"
)

func main() {
	var n int
	if _, err := fmt.Scanf("%d\n", &n); err != nil {
		return
	}

	if n%2 != 0 {
		fmt.Printf("a")
	}

	for i := 1; i <= n/2; i++ {
		if i%2 == 0 {
			fmt.Printf("aa")
		} else {
			fmt.Printf("bb")
		}
	}
	fmt.Println()
}

package main

import "fmt"

func main() {
	var n int

	fmt.Scanf("%d", &n)

	name := make([]rune, n)

	for i := 0; i < n; i++ {
		switch i % 4 {
		case 0, 1:
			name[i] = 'a'
		case 2, 3:
			name[i] = 'b'
		}
	}

	fmt.Println(string(name))
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	n := readInt()
	a := make([]byte, n)
	for i := 0; i < n; i++ {
		a[i] = byte('a' + ((i / 2) % 2))
	}
	fmt.Println(string(a))
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	var ln int
	fmt.Fscan(reader, &ln)

	str := "aabb"
	for len(str) < ln {
		str += str
	}

	fmt.Println(str[:ln])
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	var ln int
	fmt.Fscan(reader, &ln)

	str := ""
	for i := 1; i <= ln/2+1; i++ {
		if i%2 == 1 {
			str += "aa"
		} else {
			str += "bb"
		}
	}

	fmt.Println(str[:ln])
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	var ln int
	fmt.Fscan(reader, &ln)

	rt := ln / 2
	str := ""

	for i := 1; i <= rt; i++ {
		if i%2 == 1 {
			str += "aa"
		} else {
			str += "bb"
		}
	}

	if ln%2 == 0 {
		fmt.Println(str)
		return
	}

	if (ln/2)%2 == 1 {
		str += "b"
	} else {
		str += "a"
	}
	fmt.Println(str)
}

package main

import "fmt"
import "bytes"

func main() {
    var n int
    fmt.Scan(&n)

    var buf bytes.Buffer
    for i:=0; i < n; i++ {
        if i%4 < 2 {
            buf.WriteString("a")
        } else {
            buf.WriteString("b")
        }
    }
    fmt.Print(buf.String())
}

package main

import (
	"fmt"
)

func main() {
	var n int
	var s string
	s = "aabb"
	fmt.Scanf("%d", &n)
	for len(s) < n {
		s = s + s
	}
	fmt.Println(s[:n])
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

const pattern string = "abba"

func Solve(io *FastIO) {
	N := io.NextInt()

	sb := new(bytes.Buffer)
	for i := 0; i < N; i++ {
		sb.WriteByte(pattern[i % 4]);
	}
	io.Println(sb.String())
}

type FastIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}

func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = (res * 10) + int(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}

func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextInt()
	}
	return arr
}

func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}

func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextLong()
	}
	return arr
}

func (io *FastIO) NextString() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}

func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}

func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}

func IsLineBreakChar(c byte) bool {
	switch c {
		case 0, '\n', '\r':
			return true
		default:
			return false
	}
}

func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Solve(&io)
	io.FlushOutput()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	N := sc.NextInt()

	s := make([]byte, N)
	for i := 0; i < N; i++ {
		s[i] = byte((i/2)%2 + 'a')
	}
	fmt.Println(string(s))

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	n := readInt()
	a := make([]byte, n)
	for i := 0; i < n; i++ {
		a[i] = byte('d' + (i % 3))
	}
	fmt.Println(string(a))
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	var ln int
	fmt.Fscan(reader, &ln)

	rt := ln / 3

	for rt > 0 {
		fmt.Print("abc")
		rt--
	}

	if ln%3 == 1 {
		fmt.Println("a")
	} else if ln%3 == 2 {
		fmt.Println("ab")
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	var ln int
	fmt.Fscan(reader, &ln)

	rt := ln / 3
	str := ""

	for rt > 0 {
		str += "aab"

		rt--
		if len(str) < ln {
			str += "c"
		}
	}

	if (ln-len(str))%3 == 1 {
		str += "a"
	} else if (ln-len(str))%3 == 2 {
		str += "ab"
	}
	fmt.Println(str)
}

package main

import (
	"fmt"
)

func main() {
	var n int
	var s string
	//var b = [3]byte{'a', 'b', 'c'}
	fmt.Scanf("%d", &n)
	for len(s) < n {
		s = s + "aabbaacbbacbbaabb"
	}
	fmt.Println(s[:n])
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	N := sc.NextInt()

	s := make([]byte, N)
	for i := 0; i < N; i++ {
		s[i] = byte((i % 3) + 'a')
	}
	fmt.Println(string(s))

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	N := sc.NextInt()

	s := make([]byte, N)
	s[0] = 'c'
	for i := 1; i < N; i++ {
		s[i] = byte(((i + 1) % 3) + 'a')
	}
	fmt.Println(string(s))

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	N := sc.NextInt()

	s := make([]byte, N)
	s[0] = 'a'
	for i := 1; i < N; i++ {
		s[i] = byte(((i + 2) % 3) + 'a')
	}
	fmt.Println(string(s))

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


For each string s consisting of characters '0' and '1' one can define four integers a00, a01, a10 and a11, where axy is the number of subsequences of length 2 of the string s equal to the sequence {x, y}. In these problem you are given four integers a00, a01, a10, a11 and have to find any non-empty string s that matches them, or determine that there is no such string. One can prove that if at least one answer exists, there exists an answer of length no more than 1 000 000.

The only line of the input contains four non-negative integers a00, a01, a10 and a11. Each of them doesn't exceed 109.

If there exists a non-empty string that matches four integers from the input, print it in the only line of the output. Otherwise, print "Impossible". The length of your answer must not exceed 1 000 000.

package main

import (
	"bufio"
	"math"
	"os"
	"strconv"
)

const limit = 1000000

func print(a01 int, a10 int, zero int, one int) bool {
	total := zero + one
	for i := 0; i < total; i++ {
		if (zero > 0) && (a01 >= one) {
			out.WriteByte('0')
			zero--
			a01 -= one
		} else if (one > 0) && (a10 >= zero) {
			out.WriteByte('1')
			one--
			a10 -= zero
		} else {
			return false
		}
	}
	return true
}

func find(n int) []int {
	delta := 1 + 8*int64(n)
	r := int64(math.Sqrt(float64(delta)))
	if (r*r == delta) && (r%2 == 1) {
		x1 := int((1 - r) / 2)
		x2 := int((1 + r) / 2)
		return []int{x1, x2}
	}
	return []int{}
}

func run(a00 int, a01 int, a10 int, a11 int) bool {
	szero := find(a00)
	sone := find(a11)
	for _, zero := range szero {
		for _, one := range sone {
			if (zero >= 0) && (one >= 0) && (zero+one > 0) && (zero*one == a10+a01) {
				if print(a01, a10, zero, one) {
					return true
				}
			}
		}
	}
	write("Impossible")
	return false
}

func main() {
	in = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)

	in.Split(bufio.ScanWords)
	defer out.Flush()

	a00 := readInt()
	a01 := readInt()
	a10 := readInt()
	a11 := readInt()

	run(a00, a01, a10, a11)
}

func min(x int, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x int, y int) int {
	if x < y {
		return y
	}
	return x
}

// Heap
type Node struct {
	name  int
	value int64
	index int
}

type NodeList []*Node

func (nodes NodeList) Len() int {
	return len(nodes)
}

func (nodes NodeList) Less(i int, j int) bool {
	return nodes[i].value < nodes[j].value
}

func (nodes NodeList) Swap(i int, j int) {
	nodes[i], nodes[j] = nodes[j], nodes[i]
	nodes[i].index = i
	nodes[j].index = j
}

func (nodes *NodeList) Push(x interface{}) {
	node := x.(*Node)
	node.index = len(*nodes)
	*nodes = append(*nodes, node)
}

func (nodes *NodeList) Pop() interface{} {
	s := *nodes
	last := len(s) - 1
	r := s[last]
	*nodes = s[:last]
	r.index = -1
	return r
}

// Int64Slice Sort
type Int64Slice []int64

func (s Int64Slice) Len() int               { return len(s) }
func (s Int64Slice) Less(i int, j int) bool { return s[i] < s[j] }
func (s Int64Slice) Swap(i int, j int)      { s[i], s[j] = s[j], s[i] }

// Input and Output
var in *bufio.Scanner
var out *bufio.Writer

func readString() string {
	in.Scan()
	return in.Text()
}

func readInt() int {
	in.Scan()
	val, _ := strconv.Atoi(in.Text())
	return val
}

func readInt64() int64 {
	in.Scan()
	val, _ := strconv.ParseInt(in.Text(), 10, 64)
	return val
}

func readFloat64() float64 {
	in.Scan()
	val, _ := strconv.ParseFloat(in.Text(), 64)
	return val
}

func write(args ...interface{}) {
	for i, e := range args {
		switch e.(type) {
		case string:
			out.WriteString(e.(string))
		case int:
			out.WriteString(strconv.Itoa(e.(int)))
		case int64:
			out.WriteString(strconv.FormatInt(e.(int64), 10))
		case float64:
			out.WriteString(strconv.FormatFloat(e.(float64), 'f', -1, 64))
		case []string:
			a := e.([]string)
			for j, x := range a {
				out.WriteString(x)
				if j+1 < len(a) {
					out.WriteByte(' ')
				}
			}
		case []int:
			a := e.([]int)
			for j, x := range a {
				out.WriteString(strconv.Itoa(x))
				if j+1 < len(a) {
					out.WriteByte(' ')
				}

			}
		case []int64:
			a := e.([]int64)
			for j, x := range a {
				out.WriteString(strconv.FormatInt(x, 10))
				if j+1 < len(a) {
					out.WriteByte(' ')
				}

			}
		case []float64:
			a := e.([]float64)
			for j, x := range a {
				out.WriteString(strconv.FormatFloat(x, 'f', -1, 64))
				if j+1 < len(a) {
					out.WriteByte(' ')
				}

			}
		default:
			out.WriteString("###")
		}
		if i+1 < len(args) {
			out.WriteByte(' ')
		}
	}
}

func writeln(args ...interface{}) {
	write(args)
	out.WriteByte('\n')
}

package main

import (
	"bufio"
	"math"
	"os"
	"strconv"
)

const limit = 1000000

func print(digit byte, n int) {
	for i := 0; i < n; i++ {
		out.WriteByte(digit)
	}
}

func solution(c int, a00 int) []int {
	delta := 1 + 8*a00
	if delta >= 0 {
		r := int(math.Sqrt(float64(delta)))
		if (r*r == delta) && (r%2 == 1) {
			x1 := (1 - 2*c + r) / 2
			x2 := (1 - 2*c - r) / 2
			return []int{x1, x2}
		}
	}
	return []int{}
}

func good(a00 int, a01 int, a10 int, a11 int, da byte, db byte, b int, c int) bool {
	as := solution(c, a00)
	ds := solution(b, a11)
	for _, a := range as {
		for _, d := range ds {
			if (a >= 0) && (d >= 0) && (a+b+c+d <= limit) {
				print(da, a)
				print(db, b)
				print(da, c)
				print(db, d)
				return true
			}
		}
	}
	return false
}

func find(a00 int, a01 int, a10 int, a11 int, da byte, db byte) bool {
	n := limit
	if a10 == 0 {
		n = 0
		for c := 0; c <= n; c++ {
			if good(a00, a01, a10, a11, da, db, 0, c) || good(a00, a01, a10, a11, da, db, c, 0) {
				return true
			}
		}
	}
	for b := 1; b <= n; b++ {
		if a10%b == 0 {
			c := a10 / b
			if good(a00, a01, a10, a11, da, db, b, c) || good(a00, a01, a10, a11, da, db, c, b) {
				return true
			}
		}
	}
	return false
}

func main() {
	in = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)

	in.Split(bufio.ScanWords)
	defer out.Flush()

	a00 := readInt()
	a01 := readInt()
	a10 := readInt()
	a11 := readInt()

	if find(a00, a01, a10, a11, '0', '1') {
		return
	}

	if find(a11, a10, a01, a00, '1', '0') {
		return
	}

	write("Impossible")
}

func min(x int, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x int, y int) int {
	if x < y {
		return y
	}
	return x
}

// Heap
type Node struct {
	name  int
	value int64
	index int
}

type NodeList []*Node

func (nodes NodeList) Len() int {
	return len(nodes)
}

func (nodes NodeList) Less(i int, j int) bool {
	return nodes[i].value < nodes[j].value
}

func (nodes NodeList) Swap(i int, j int) {
	nodes[i], nodes[j] = nodes[j], nodes[i]
	nodes[i].index = i
	nodes[j].index = j
}

func (nodes *NodeList) Push(x interface{}) {
	node := x.(*Node)
	node.index = len(*nodes)
	*nodes = append(*nodes, node)
}

func (nodes *NodeList) Pop() interface{} {
	s := *nodes
	last := len(s) - 1
	r := s[last]
	*nodes = s[:last]
	r.index = -1
	return r
}

// Int64Slice Sort
type Int64Slice []int64

func (s Int64Slice) Len() int               { return len(s) }
func (s Int64Slice) Less(i int, j int) bool { return s[i] < s[j] }
func (s Int64Slice) Swap(i int, j int)      { s[i], s[j] = s[j], s[i] }

// Input and Output
var in *bufio.Scanner
var out *bufio.Writer

func readString() string {
	in.Scan()
	return in.Text()
}

func readInt() int {
	in.Scan()
	val, _ := strconv.Atoi(in.Text())
	return val
}

func readInt64() int64 {
	in.Scan()
	val, _ := strconv.ParseInt(in.Text(), 10, 64)
	return val
}

func readFloat64() float64 {
	in.Scan()
	val, _ := strconv.ParseFloat(in.Text(), 64)
	return val
}

func write(args ...interface{}) {
	for i, e := range args {
		switch e.(type) {
		case string:
			out.WriteString(e.(string))
		case int:
			out.WriteString(strconv.Itoa(e.(int)))
		case int64:
			out.WriteString(strconv.FormatInt(e.(int64), 10))
		case float64:
			out.WriteString(strconv.FormatFloat(e.(float64), 'f', -1, 64))
		case []string:
			a := e.([]string)
			for j, x := range a {
				out.WriteString(x)
				if j+1 < len(a) {
					out.WriteByte(' ')
				}
			}
		case []int:
			a := e.([]int)
			for j, x := range a {
				out.WriteString(strconv.Itoa(x))
				if j+1 < len(a) {
					out.WriteByte(' ')
				}

			}
		case []int64:
			a := e.([]int64)
			for j, x := range a {
				out.WriteString(strconv.FormatInt(x, 10))
				if j+1 < len(a) {
					out.WriteByte(' ')
				}

			}
		case []float64:
			a := e.([]float64)
			for j, x := range a {
				out.WriteString(strconv.FormatFloat(x, 'f', -1, 64))
				if j+1 < len(a) {
					out.WriteByte(' ')
				}

			}
		default:
			out.WriteString("###")
		}
		if i+1 < len(args) {
			out.WriteByte(' ')
		}
	}
	out.WriteByte('\n')
}

package main

import (
	"bufio"
	"math"
	"os"
	"strconv"
)

const limit = 1000000

func print(digit byte, n int) {
	for i := 0; i < n; i++ {
		out.WriteByte(digit)
	}
}

func solution(c int, a00 int) []int {
	delta := 1 + 8*a00
	if delta >= 0 {
		r := int(math.Sqrt(float64(delta)))
		if (r*r == delta) && (r%2 == 1) {
			x1 := (1 - 2*c + r) / 2
			x2 := (1 - 2*c - r) / 2
			return []int{x1, x2}
		}
	}
	return []int{}
}

func good(a00 int, a01 int, a10 int, a11 int, da byte, db byte, b int, c int) bool {
	as := solution(c, a00)
	ds := solution(b, a11)
	for _, a := range as {
		for _, d := range ds {
			if (a >= 0) && (d >= 0) && (a01 == a*(b+d)+c*d) && (a+b+c+d <= limit) {
				print(da, a)
				print(db, b)
				print(da, c)
				print(db, d)
				return true
			}
		}
	}
	return false
}

func find(a00 int, a01 int, a10 int, a11 int, da byte, db byte) bool {
	n := limit
	if a10 == 0 {
		n = 0
		for c := 0; c <= n; c++ {
			if good(a00, a01, a10, a11, da, db, 0, c) || good(a00, a01, a10, a11, da, db, c, 0) {
				return true
			}
		}
	}
	for b := 1; b <= n; b++ {
		if a10%b == 0 {
			c := a10 / b
			if good(a00, a01, a10, a11, da, db, b, c) || good(a00, a01, a10, a11, da, db, c, b) {
				return true
			}
		}
	}
	return false
}

func main() {
	in = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)

	in.Split(bufio.ScanWords)
	defer out.Flush()

	a00 := readInt()
	a01 := readInt()
	a10 := readInt()
	a11 := readInt()

	if find(a00, a01, a10, a11, '0', '1') {
		return
	}

	if find(a11, a10, a01, a00, '1', '0') {
		return
	}

	write("Impossible")
}

func min(x int, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x int, y int) int {
	if x < y {
		return y
	}
	return x
}

// Heap
type Node struct {
	name  int
	value int64
	index int
}

type NodeList []*Node

func (nodes NodeList) Len() int {
	return len(nodes)
}

func (nodes NodeList) Less(i int, j int) bool {
	return nodes[i].value < nodes[j].value
}

func (nodes NodeList) Swap(i int, j int) {
	nodes[i], nodes[j] = nodes[j], nodes[i]
	nodes[i].index = i
	nodes[j].index = j
}

func (nodes *NodeList) Push(x interface{}) {
	node := x.(*Node)
	node.index = len(*nodes)
	*nodes = append(*nodes, node)
}

func (nodes *NodeList) Pop() interface{} {
	s := *nodes
	last := len(s) - 1
	r := s[last]
	*nodes = s[:last]
	r.index = -1
	return r
}

// Int64Slice Sort
type Int64Slice []int64

func (s Int64Slice) Len() int               { return len(s) }
func (s Int64Slice) Less(i int, j int) bool { return s[i] < s[j] }
func (s Int64Slice) Swap(i int, j int)      { s[i], s[j] = s[j], s[i] }

// Input and Output
var in *bufio.Scanner
var out *bufio.Writer

func readString() string {
	in.Scan()
	return in.Text()
}

func readInt() int {
	in.Scan()
	val, _ := strconv.Atoi(in.Text())
	return val
}

func readInt64() int64 {
	in.Scan()
	val, _ := strconv.ParseInt(in.Text(), 10, 64)
	return val
}

func readFloat64() float64 {
	in.Scan()
	val, _ := strconv.ParseFloat(in.Text(), 64)
	return val
}

func write(args ...interface{}) {
	for i, e := range args {
		switch e.(type) {
		case string:
			out.WriteString(e.(string))
		case int:
			out.WriteString(strconv.Itoa(e.(int)))
		case int64:
			out.WriteString(strconv.FormatInt(e.(int64), 10))
		case float64:
			out.WriteString(strconv.FormatFloat(e.(float64), 'f', -1, 64))
		case []string:
			a := e.([]string)
			for j, x := range a {
				out.WriteString(x)
				if j+1 < len(a) {
					out.WriteByte(' ')
				}
			}
		case []int:
			a := e.([]int)
			for j, x := range a {
				out.WriteString(strconv.Itoa(x))
				if j+1 < len(a) {
					out.WriteByte(' ')
				}

			}
		case []int64:
			a := e.([]int64)
			for j, x := range a {
				out.WriteString(strconv.FormatInt(x, 10))
				if j+1 < len(a) {
					out.WriteByte(' ')
				}

			}
		case []float64:
			a := e.([]float64)
			for j, x := range a {
				out.WriteString(strconv.FormatFloat(x, 'f', -1, 64))
				if j+1 < len(a) {
					out.WriteByte(' ')
				}

			}
		default:
			out.WriteString("###")
		}
		if i+1 < len(args) {
			out.WriteByte(' ')
		}
	}
	out.WriteByte('\n')
}

package main

import (
	"bufio"
	"math"
	"os"
	"strconv"
)

const limit = 1000000

func print(a01 int, a10 int, zero int, one int) bool {
	total := zero + one
	for i := 0; i < total; i++ {
		if (zero > 0) && (a01 >= one) {
			out.WriteByte('0')
			zero--
			a01 -= one
		} else if (one > 0) && (a10 >= zero) {
			out.WriteByte('1')
			one--
			a10 -= zero
		} else {
			return false
		}
	}
	return true
}

func find(n int) []int {
	delta := 1 + 8*n
	r := int(math.Sqrt(float64(delta)))
	if (r*r == delta) && (r%2 == 1) {
		x1 := (1 - r) / 2
		x2 := (1 + r) / 2
		return []int{x1, x2}
	}
	return []int{}
}

func run(a00 int, a01 int, a10 int, a11 int) bool {
	szero := find(a00)
	sone := find(a11)
	for _, zero := range szero {
		for _, one := range sone {
			if (zero >= 0) && (one >= 0) && (zero+one > 0) && (zero*one == a10+a01) {
				if print(a01, a10, zero, one) {
					return true
				}
			}
		}
	}
	write("Impossible")
	return false
}

func main() {
	in = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)

	in.Split(bufio.ScanWords)
	defer out.Flush()

	a00 := readInt()
	a01 := readInt()
	a10 := readInt()
	a11 := readInt()

	run(a00, a01, a10, a11)
}

func min(x int, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x int, y int) int {
	if x < y {
		return y
	}
	return x
}

// Heap
type Node struct {
	name  int
	value int64
	index int
}

type NodeList []*Node

func (nodes NodeList) Len() int {
	return len(nodes)
}

func (nodes NodeList) Less(i int, j int) bool {
	return nodes[i].value < nodes[j].value
}

func (nodes NodeList) Swap(i int, j int) {
	nodes[i], nodes[j] = nodes[j], nodes[i]
	nodes[i].index = i
	nodes[j].index = j
}

func (nodes *NodeList) Push(x interface{}) {
	node := x.(*Node)
	node.index = len(*nodes)
	*nodes = append(*nodes, node)
}

func (nodes *NodeList) Pop() interface{} {
	s := *nodes
	last := len(s) - 1
	r := s[last]
	*nodes = s[:last]
	r.index = -1
	return r
}

// Int64Slice Sort
type Int64Slice []int64

func (s Int64Slice) Len() int               { return len(s) }
func (s Int64Slice) Less(i int, j int) bool { return s[i] < s[j] }
func (s Int64Slice) Swap(i int, j int)      { s[i], s[j] = s[j], s[i] }

// Input and Output
var in *bufio.Scanner
var out *bufio.Writer

func readString() string {
	in.Scan()
	return in.Text()
}

func readInt() int {
	in.Scan()
	val, _ := strconv.Atoi(in.Text())
	return val
}

func readInt64() int64 {
	in.Scan()
	val, _ := strconv.ParseInt(in.Text(), 10, 64)
	return val
}

func readFloat64() float64 {
	in.Scan()
	val, _ := strconv.ParseFloat(in.Text(), 64)
	return val
}

func write(args ...interface{}) {
	for i, e := range args {
		switch e.(type) {
		case string:
			out.WriteString(e.(string))
		case int:
			out.WriteString(strconv.Itoa(e.(int)))
		case int64:
			out.WriteString(strconv.FormatInt(e.(int64), 10))
		case float64:
			out.WriteString(strconv.FormatFloat(e.(float64), 'f', -1, 64))
		case []string:
			a := e.([]string)
			for j, x := range a {
				out.WriteString(x)
				if j+1 < len(a) {
					out.WriteByte(' ')
				}
			}
		case []int:
			a := e.([]int)
			for j, x := range a {
				out.WriteString(strconv.Itoa(x))
				if j+1 < len(a) {
					out.WriteByte(' ')
				}

			}
		case []int64:
			a := e.([]int64)
			for j, x := range a {
				out.WriteString(strconv.FormatInt(x, 10))
				if j+1 < len(a) {
					out.WriteByte(' ')
				}

			}
		case []float64:
			a := e.([]float64)
			for j, x := range a {
				out.WriteString(strconv.FormatFloat(x, 'f', -1, 64))
				if j+1 < len(a) {
					out.WriteByte(' ')
				}

			}
		default:
			out.WriteString("###")
		}
		if i+1 < len(args) {
			out.WriteByte(' ')
		}
	}
}

func writeln(args ...interface{}) {
	write(args)
	out.WriteByte('\n')
}