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

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

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

i = A("i")
g = B("g")
m = C("m")
n = A("n")

i.t = g
g.u = n
m.r = g
m.t = n
m.p = i
n.t = g
assert g.u.t.u.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

i = A("i")
g = B("g")
m = C("m")
n = A("n")

i.t = g
g.u = n
m.r = g
m.t = n
m.p = i
n.t = g
assert g.u.t.u.txt == "n"