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

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: A = None
        self.w: B = None
        self.x: B = None
        self.q: C = None
        self.v: D = None
        self.txt = txt

j = A("j")
d = B("d")
f = C("f")
g = D("g")
n = E("n")
k = A("k")

j.u = n
j.o = f
d.w = n
f.p = j
f.u = n
f.x = n
g.x = n
g.r = n
g.u = f
g.q = j
g.z = d
n.r = j
n.w = d
n.x = d
n.q = f
n.v = g
k.u = n
k.o = f
assert n.v.u.p.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: E = None
        self.o: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: A = None
        self.w: B = None
        self.x: B = None
        self.q: C = None
        self.v: D = None
        self.txt = txt

j = A("j")
d = B("d")
f = C("f")
g = D("g")
n = E("n")
k = A("k")

j.u = n
j.o = f
d.w = n
f.p = j
f.u = n
f.x = n
g.x = n
g.r = n
g.u = f
g.q = j
g.z = d
n.r = j
n.w = d
n.x = d
n.q = f
n.v = g
k.u = n
k.o = f
assert n.v.u.p.u.v.txt == "g"