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

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

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

j = A("j")
g = B("g")
i = C("i")
n = A("n")
d = B("d")

j.t = n
g.u = i
i.w = n
n.t = j
d.u = i
assert n.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.u: C = None
        self.txt = txt

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

j = A("j")
g = B("g")
i = C("i")
n = A("n")
d = B("d")

j.t = n
g.u = i
i.w = n
n.t = j
d.u = i
assert n.t.t.t.txt == "j"