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.x: A = None
        self.txt = txt

h = A("h")
b = B("b")
m = B("m")
j = B("j")
d = A("d")
k = B("k")
l = A("l")
g = B("g")
n = A("n")

h.z = l
h.t = m
b.x = d
m.x = l
j.x = l
d.z = h
d.t = b
k.x = h
l.z = n
l.t = g
g.x = h
n.z = d
n.t = g
assert m.x.z.t.x.z.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.x: A = None
        self.txt = txt

h = A("h")
b = B("b")
m = B("m")
j = B("j")
d = A("d")
k = B("k")
l = A("l")
g = B("g")
n = A("n")

h.z = l
h.t = m
b.x = d
m.x = l
j.x = l
d.z = h
d.t = b
k.x = h
l.z = n
l.t = g
g.x = h
n.z = d
n.t = g
assert m.x.z.t.x.z.txt == "l"