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

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

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

d = A("d")
c = B("c")
h = C("h")

d.w = h
c.v = d
c.o = d
c.q = h
h.v = d
h.r = d
h.s = c
assert d.w.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

d = A("d")
c = B("c")
h = C("h")

d.w = h
c.v = d
c.o = d
c.q = h
h.v = d
h.r = d
h.s = c
assert d.w.s.q.txt == "h"