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

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

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

i = A("i")
c = B("c")
k = C("k")
a = C("a")

i.p = a
c.p = k
c.w = k
c.z = i
k.w = c
k.v = c
k.q = a
a.w = c
a.v = c
a.q = k
assert i.p.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

i = A("i")
c = B("c")
k = C("k")
a = C("a")

i.p = a
c.p = k
c.w = k
c.z = i
k.w = c
k.v = c
k.q = a
a.w = c
a.v = c
a.q = k
assert i.p.w.z.txt == "i"