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

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

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.s: E = None
        self.t: B = None
        self.v: E = None
        self.z: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.y: D = None
        self.s: D = None
        self.u: A = None
        self.txt = txt

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

f.y = n
f.q = m
f.x = g
n.z = f
n.t = b
n.o = m
n.x = m
n.u = g
m.v = f
m.o = f
g.u = f
g.s = b
g.v = b
g.t = n
g.z = n
b.y = g
b.s = g
b.u = f
assert b.u.x.u.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.q: C = None
        self.x: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.s: E = None
        self.t: B = None
        self.v: E = None
        self.z: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.y: D = None
        self.s: D = None
        self.u: A = None
        self.txt = txt

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

f.y = n
f.q = m
f.x = g
n.z = f
n.t = b
n.o = m
n.x = m
n.u = g
m.v = f
m.o = f
g.u = f
g.s = b
g.v = b
g.t = n
g.z = n
b.y = g
b.s = g
b.u = f
assert b.u.x.u.x.z.txt == "n"