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

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

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

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

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

c.u = i
c.s = j
c.r = m
a.t = i
a.w = i
a.p = c
a.x = m
e.q = j
e.u = a
e.w = i
m.s = n
n.u = a
n.s = e
n.r = m
j.q = e
j.u = i
j.w = i
i.t = a
i.w = a
i.p = n
i.x = m
assert a.p.r.s.s.u.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.s: C = None
        self.r: D = None
        self.txt = txt

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

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

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

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

c.u = i
c.s = j
c.r = m
a.t = i
a.w = i
a.p = c
a.x = m
e.q = j
e.u = a
e.w = i
m.s = n
n.u = a
n.s = e
n.r = m
j.q = e
j.u = i
j.w = i
i.t = a
i.w = a
i.p = n
i.x = m
assert a.p.r.s.s.u.x.s.txt == "n"