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

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

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

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

j = A("j")
m = B("m")
a = C("a")
d = D("d")
f = B("f")
n = A("n")

j.r = d
j.p = m
j.s = a
j.o = f
m.u = n
m.p = d
m.t = f
a.v = m
a.q = d
d.s = a
d.r = a
f.u = n
f.p = d
f.t = m
n.r = d
n.p = f
n.s = a
n.o = m
assert n.o.p.s.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.p: B = None
        self.s: C = None
        self.o: B = None
        self.txt = txt

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

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

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

j = A("j")
m = B("m")
a = C("a")
d = D("d")
f = B("f")
n = A("n")

j.r = d
j.p = m
j.s = a
j.o = f
m.u = n
m.p = d
m.t = f
a.v = m
a.q = d
d.s = a
d.r = a
f.u = n
f.p = d
f.t = m
n.r = d
n.p = f
n.s = a
n.o = m
assert n.o.p.s.q.r.txt == "a"