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

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

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

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

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

f.w = i
f.s = h
h.q = c
h.x = k
n.z = h
m.q = e
m.v = e
b.w = m
b.s = h
i.q = e
i.v = h
e.q = n
e.x = f
l.w = m
l.s = e
k.w = i
k.s = e
c.z = h
assert m.v.x.s.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.s: B = None
        self.txt = txt

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

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

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

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

f.w = i
f.s = h
h.q = c
h.x = k
n.z = h
m.q = e
m.v = e
b.w = m
b.s = h
i.q = e
i.v = h
e.q = n
e.x = f
l.w = m
l.s = e
k.w = i
k.s = e
c.z = h
assert m.v.x.s.x.s.txt == "e"