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

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

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

class D:
    def __init__(self, txt: str):
        self.z: A = None
        self.x: A = None
        self.w: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.z: A = None
        self.x: A = None
        self.w: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

f.p = m
f.t = m
f.q = m
f.u = a
f.r = j
n.q = a
n.o = a
n.t = f
n.w = f
n.u = m
j.s = n
j.p = f
m.z = f
m.x = f
m.w = a
a.q = n
assert m.w.q.o.q.t.txt == "f"