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

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

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

class D:
    def __init__(self, txt: str):
        self.p: A = None
        self.z: D = None
        self.o: B = None
        self.y: B = None
        self.txt = txt

l = A("l")
d = B("d")
h = C("h")
g = D("g")
b = D("b")

l.q = b
l.s = g
d.x = g
d.z = h
d.u = h
h.v = l
h.w = l
h.s = l
g.p = l
g.z = b
g.o = d
g.y = d
b.p = l
b.z = g
b.o = d
b.y = d
assert d.x.y.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.s: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.p: A = None
        self.z: D = None
        self.o: B = None
        self.y: B = None
        self.txt = txt

l = A("l")
d = B("d")
h = C("h")
g = D("g")
b = D("b")

l.q = b
l.s = g
d.x = g
d.z = h
d.u = h
h.v = l
h.w = l
h.s = l
g.p = l
g.z = b
g.o = d
g.y = d
b.p = l
b.z = g
b.o = d
b.y = d
assert d.x.y.u.w.txt == "l"