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

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

f = A("f")
m = B("m")
a = B("a")
h = B("h")
j = B("j")
l = A("l")
n = B("n")
k = A("k")
b = A("b")
c = A("c")

f.o = a
f.y = l
m.z = l
a.z = l
h.z = c
j.z = c
l.o = n
l.y = b
n.z = c
k.o = a
k.y = f
b.o = n
b.y = l
c.o = j
c.y = f
assert k.y.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.y: A = None
        self.txt = txt

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

f = A("f")
m = B("m")
a = B("a")
h = B("h")
j = B("j")
l = A("l")
n = B("n")
k = A("k")
b = A("b")
c = A("c")

f.o = a
f.y = l
m.z = l
a.z = l
h.z = c
j.z = c
l.o = n
l.y = b
n.z = c
k.o = a
k.y = f
b.o = n
b.y = l
c.o = j
c.y = f
assert k.y.o.z.txt == "l"