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

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

b = A("b")
a = B("a")
n = B("n")
m = B("m")
h = B("h")
k = A("k")
c = B("c")
d = A("d")

b.v = c
b.y = d
a.t = c
a.z = c
n.t = h
n.z = h
m.t = h
m.z = a
h.t = n
h.z = m
k.v = n
k.y = b
c.t = m
c.z = m
d.v = c
d.y = b
assert a.t.t.z.t.t.t.z.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.y: A = None
        self.txt = txt

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

b = A("b")
a = B("a")
n = B("n")
m = B("m")
h = B("h")
k = A("k")
c = B("c")
d = A("d")

b.v = c
b.y = d
a.t = c
a.z = c
n.t = h
n.z = h
m.t = h
m.z = a
h.t = n
h.z = m
k.v = n
k.y = b
c.t = m
c.z = m
d.v = c
d.y = b
assert a.t.t.z.t.t.t.z.txt == "m"