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

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

m = A("m")
i = B("i")
k = B("k")
a = B("a")
g = A("g")
l = B("l")

m.t = g
m.p = l
i.v = m
i.z = a
k.v = g
k.z = a
a.v = m
a.z = l
g.t = m
g.p = a
l.v = m
l.z = i
assert g.p.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.p: B = None
        self.txt = txt

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

m = A("m")
i = B("i")
k = B("k")
a = B("a")
g = A("g")
l = B("l")

m.t = g
m.p = l
i.v = m
i.z = a
k.v = g
k.z = a
a.v = m
a.z = l
g.t = m
g.p = a
l.v = m
l.z = i
assert g.p.z.z.z.z.z.txt == "i"