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

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

class C:
    def __init__(self, txt: str):
        self.p: D = None
        self.r: D = None
        self.x: C = None
        self.txt = txt

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

d = A("d")
j = B("j")
n = C("n")
m = D("m")
f = C("f")
k = B("k")
i = C("i")
b = C("b")

d.s = j
d.x = k
d.q = n
j.v = m
j.q = m
j.o = i
n.p = m
n.r = m
n.x = f
m.r = j
m.s = j
m.y = b
m.u = b
f.p = m
f.r = m
f.x = i
k.v = m
k.q = m
k.o = i
i.p = m
i.r = m
i.x = f
b.p = m
b.r = m
b.x = i
assert b.p.u.x.p.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.x: B = None
        self.q: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: D = None
        self.r: D = None
        self.x: C = None
        self.txt = txt

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

d = A("d")
j = B("j")
n = C("n")
m = D("m")
f = C("f")
k = B("k")
i = C("i")
b = C("b")

d.s = j
d.x = k
d.q = n
j.v = m
j.q = m
j.o = i
n.p = m
n.r = m
n.x = f
m.r = j
m.s = j
m.y = b
m.u = b
f.p = m
f.r = m
f.x = i
k.v = m
k.q = m
k.o = i
i.p = m
i.r = m
i.x = f
b.p = m
b.r = m
b.x = i
assert b.p.u.x.p.y.r.txt == "m"