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

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

i = A("i")
f = B("f")
k = B("k")
m = A("m")
l = A("l")
j = B("j")
e = B("e")
h = A("h")

i.y = k
f.o = h
f.u = m
k.o = i
k.u = h
m.y = k
l.y = k
j.o = h
j.u = i
e.o = l
e.u = l
h.y = k
assert k.o.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

i = A("i")
f = B("f")
k = B("k")
m = A("m")
l = A("l")
j = B("j")
e = B("e")
h = A("h")

i.y = k
f.o = h
f.u = m
k.o = i
k.u = h
m.y = k
l.y = k
j.o = h
j.u = i
e.o = l
e.u = l
h.y = k
assert k.o.y.u.txt == "h"