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

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

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

m = A("m")
n = B("n")
j = C("j")

m.s = j
n.t = j
j.y = m
assert m.s.y.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

m = A("m")
n = B("n")
j = C("j")

m.s = j
n.t = j
j.y = m
assert m.s.y.s.txt == "j"