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

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

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

k = A("k")
m = B("m")
d = C("d")

k.v = d
m.s = d
m.p = d
m.q = k
d.w = m
d.t = k
d.o = k
assert d.w.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

k = A("k")
m = B("m")
d = C("d")

k.v = d
m.s = d
m.p = d
m.q = k
d.w = m
d.t = k
d.o = k
assert d.w.q.v.txt == "d"