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

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

h = A("h")
e = B("e")
c = B("c")
i = A("i")
j = B("j")
d = A("d")
l = A("l")
m = A("m")
f = B("f")
b = B("b")

h.z = m
h.t = f
e.o = d
e.x = h
c.o = i
c.x = d
i.z = l
i.t = e
j.o = m
j.x = l
d.z = m
d.t = b
l.z = m
l.t = c
m.z = l
m.t = j
f.o = h
f.x = l
b.o = l
b.x = m
assert l.t.x.z.z.t.x.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.t: B = None
        self.txt = txt

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

h = A("h")
e = B("e")
c = B("c")
i = A("i")
j = B("j")
d = A("d")
l = A("l")
m = A("m")
f = B("f")
b = B("b")

h.z = m
h.t = f
e.o = d
e.x = h
c.o = i
c.x = d
i.z = l
i.t = e
j.o = m
j.x = l
d.z = m
d.t = b
l.z = m
l.t = c
m.z = l
m.t = j
f.o = h
f.x = l
b.o = l
b.x = m
assert l.t.x.z.z.t.x.z.t.txt == "j"