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

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

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

i = A("i")
c = B("c")
m = C("m")

i.x = c
c.x = m
c.t = m
m.p = i
assert i.x.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

i = A("i")
c = B("c")
m = C("m")

i.x = c
c.x = m
c.t = m
m.p = i
assert i.x.t.p.txt == "i"