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

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

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

class D:
    def __init__(self, txt: str):
        self.r: D = None
        self.y: A = None
        self.z: B = None
        self.p: B = None
        self.txt = txt

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

n.s = f
n.u = f
n.q = f
m.s = k
m.z = k
m.o = k
m.t = n
f.s = d
h.r = d
h.y = n
h.z = m
h.p = b
k.r = h
k.y = n
k.z = b
k.p = b
b.s = d
b.z = h
b.o = k
b.t = n
d.r = h
d.y = n
d.z = m
d.p = b
assert f.s.r.p.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.u: C = None
        self.q: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.r: D = None
        self.y: A = None
        self.z: B = None
        self.p: B = None
        self.txt = txt

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

n.s = f
n.u = f
n.q = f
m.s = k
m.z = k
m.o = k
m.t = n
f.s = d
h.r = d
h.y = n
h.z = m
h.p = b
k.r = h
k.y = n
k.z = b
k.p = b
b.s = d
b.z = h
b.o = k
b.t = n
d.r = h
d.y = n
d.z = m
d.p = b
assert f.s.r.p.z.r.txt == "d"