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

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

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

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

l = A("l")
a = B("a")
f = C("f")
i = D("i")
c = C("c")
m = C("m")
e = C("e")
d = D("d")
b = A("b")
h = A("h")

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

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

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

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

l = A("l")
a = B("a")
f = C("f")
i = D("i")
c = C("c")
m = C("m")
e = C("e")
d = D("d")
b = A("b")
h = A("h")

l.q = a
l.y = h
l.z = f
a.q = i
a.t = b
f.w = a
f.s = d
f.x = m
i.u = a
i.t = a
i.w = c
c.w = a
c.s = i
c.x = f
m.w = a
m.s = i
m.x = f
e.w = a
e.s = i
e.x = c
d.u = a
d.t = a
d.w = f
b.q = a
b.y = l
b.z = e
h.q = a
h.y = l
h.z = f
assert m.x.x.s.w.x.w.txt == "a"