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

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

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

m = A("m")
g = B("g")
k = C("k")
e = B("e")

m.t = k
m.u = k
g.p = e
k.r = m
k.u = e
k.t = g
e.p = g
assert m.u.u.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.u: C = None
        self.txt = txt

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

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

m = A("m")
g = B("g")
k = C("k")
e = B("e")

m.t = k
m.u = k
g.p = e
k.r = m
k.u = e
k.t = g
e.p = g
assert m.u.u.p.p.txt == "e"