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

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

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

m = A("m")
g = B("g")
b = C("b")

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

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

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

m = A("m")
g = B("g")
b = C("b")

m.t = g
g.y = m
b.u = g
b.t = g
b.r = m
assert b.t.y.t.txt == "g"