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

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

e = A("e")
h = B("h")
b = B("b")
f = A("f")
i = A("i")
a = B("a")
g = B("g")
m = B("m")
j = B("j")
n = A("n")

e.z = a
e.o = i
h.x = i
b.x = e
f.z = g
f.o = e
i.z = g
i.o = n
a.x = n
g.x = f
m.x = f
j.x = n
n.z = a
n.o = e
assert f.z.x.o.o.z.x.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.o: A = None
        self.txt = txt

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

e = A("e")
h = B("h")
b = B("b")
f = A("f")
i = A("i")
a = B("a")
g = B("g")
m = B("m")
j = B("j")
n = A("n")

e.z = a
e.o = i
h.x = i
b.x = e
f.z = g
f.o = e
i.z = g
i.o = n
a.x = n
g.x = f
m.x = f
j.x = n
n.z = a
n.o = e
assert f.z.x.o.o.z.x.o.z.txt == "a"