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

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

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

d = A("d")
m = B("m")
l = C("l")
h = A("h")
b = B("b")
i = C("i")
f = B("f")

d.w = h
d.q = h
d.s = f
m.w = i
l.x = i
l.u = h
h.w = d
h.q = d
h.s = f
b.w = i
i.x = l
i.u = h
f.w = l
assert h.q.s.w.x.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.q: A = None
        self.s: B = None
        self.txt = txt

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

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

d = A("d")
m = B("m")
l = C("l")
h = A("h")
b = B("b")
i = C("i")
f = B("f")

d.w = h
d.q = h
d.s = f
m.w = i
l.x = i
l.u = h
h.w = d
h.q = d
h.s = f
b.w = i
i.x = l
i.u = h
f.w = l
assert h.q.s.w.x.u.q.txt == "d"