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

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

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

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

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

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

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

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

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

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

d.q = b
d.u = b
d.w = j
l.s = j
l.p = n
b.w = c
b.x = d
j.r = b
j.u = l
j.s = d
j.t = m
n.r = b
n.u = m
n.s = d
n.t = l
c.s = j
c.p = n
m.s = j
m.p = n
assert n.r.w.p.u.p.s.txt == "d"