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

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

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

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

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

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

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

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

i.w = j
i.p = j
j.w = c
j.s = i
c.x = j
c.t = j
m.x = j
m.t = j
assert m.x.s.p.txt == "j"