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

class B:
    def __init__(self, txt: str):
        self.q: C = None
        self.p: B = None
        self.txt = txt

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

k = A("k")
i = B("i")
l = C("l")
m = B("m")
h = C("h")
f = B("f")
e = A("e")

k.t = e
i.q = h
i.p = m
l.t = e
l.v = f
m.q = l
m.p = i
h.t = e
h.v = f
f.q = l
f.p = m
e.t = k
assert k.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: C = None
        self.p: B = None
        self.txt = txt

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

k = A("k")
i = B("i")
l = C("l")
m = B("m")
h = C("h")
f = B("f")
e = A("e")

k.t = e
i.q = h
i.p = m
l.t = e
l.v = f
m.q = l
m.p = i
h.t = e
h.v = f
f.q = l
f.p = m
e.t = k
assert k.t.t.t.t.t.txt == "e"