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

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

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

k = A("k")
l = B("l")
a = C("a")

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

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

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

k = A("k")
l = B("l")
a = C("a")

k.p = l
k.q = a
k.w = a
l.t = k
a.t = k
assert k.w.t.w.txt == "a"