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

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

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

k = A("k")
e = B("e")
c = C("c")
m = B("m")

k.t = m
e.y = c
e.s = k
c.r = e
c.p = m
m.y = c
m.s = k
assert m.s.t.y.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

k = A("k")
e = B("e")
c = C("c")
m = B("m")

k.t = m
e.y = c
e.s = k
c.r = e
c.p = m
m.y = c
m.s = k
assert m.s.t.y.p.txt == "m"