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

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

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

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

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

b.p = k
b.t = k
b.r = k
b.q = m
m.o = e
m.t = n
n.p = b
n.r = b
n.u = d
n.s = d
k.r = b
e.o = m
e.t = d
d.p = b
d.r = b
d.u = n
d.s = n
assert m.t.s.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.q: B = None
        self.t: D = None
        self.r: D = None
        self.txt = txt

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

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

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

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

b.p = k
b.t = k
b.r = k
b.q = m
m.o = e
m.t = n
n.p = b
n.r = b
n.u = d
n.s = d
k.r = b
e.o = m
e.t = d
d.p = b
d.r = b
d.u = n
d.s = n
assert m.t.s.u.u.u.txt == "n"