class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: B = None
        self.w: B = None
        self.txt = txt

i = A("i")
l = B("l")
j = B("j")
n = B("n")
b = A("b")
g = A("g")

i.o = l
l.y = n
l.w = n
j.y = l
j.w = n
n.y = j
n.w = j
b.o = j
g.o = n
assert j.y.w.y.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: B = None
        self.w: B = None
        self.txt = txt

i = A("i")
l = B("l")
j = B("j")
n = B("n")
b = A("b")
g = A("g")

i.o = l
l.y = n
l.w = n
j.y = l
j.w = n
n.y = j
n.w = j
b.o = j
g.o = n
assert j.y.w.y.y.w.txt == "n"