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

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

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

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

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

h.x = l
h.z = l
l.s = m
c.s = m
g.q = l
g.t = c
g.v = b
a.s = h
e.s = m
m.x = l
m.z = l
i.q = l
i.t = e
i.v = g
b.q = l
b.t = c
b.v = i
assert a.s.z.s.z.s.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.z: B = None
        self.txt = txt

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

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

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

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

h.x = l
h.z = l
l.s = m
c.s = m
g.q = l
g.t = c
g.v = b
a.s = h
e.s = m
m.x = l
m.z = l
i.q = l
i.t = e
i.v = g
b.q = l
b.t = c
b.v = i
assert a.s.z.s.z.s.x.s.txt == "m"