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

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

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

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

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

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

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

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

d.w = c
d.r = b
d.q = b
h.u = b
h.w = d
h.v = d
b.y = h
c.u = b
c.w = d
c.v = d
assert c.u.y.u.y.txt == "h"