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

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

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

k = A("k")
e = B("e")
f = C("f")

k.t = e
k.p = f
e.y = k
e.p = f
f.q = k
f.y = e
f.w = e
assert e.p.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.p: C = None
        self.txt = txt

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

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

k = A("k")
e = B("e")
f = C("f")

k.t = e
k.p = f
e.y = k
e.p = f
f.q = k
f.y = e
f.w = e
assert e.p.w.y.txt == "k"