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

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

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

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

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

n = A("n")
b = B("b")
f = C("f")
m = D("m")
j = E("j")

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

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

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

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

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

n = A("n")
b = B("b")
f = C("f")
m = D("m")
j = E("j")

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