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

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

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

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

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

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

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

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

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

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

d.u = a
d.q = m
d.z = m
d.s = j
a.s = j
i.u = a
i.x = d
n.x = a
e.u = a
e.q = d
e.z = d
e.s = j
c.x = a
j.u = b
j.x = d
b.s = j
l.u = b
l.x = m
m.u = a
m.q = d
m.z = e
m.s = j
assert d.u.s.u.s.x.u.s.txt == "j"