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

class B:
    def __init__(self, txt: str):
        self.v: A = None
        self.z: C = None
        self.w: D = None
        self.s: C = None
        self.txt = txt

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

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

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

d = A("d")
e = B("e")
b = C("b")
g = D("g")
m = E("m")
l = C("l")
f = E("f")
i = C("i")
n = A("n")

d.z = f
e.v = n
e.z = l
e.w = g
e.s = b
b.p = e
b.s = f
g.r = i
g.x = i
g.s = e
g.u = b
g.p = f
m.o = n
l.p = e
l.s = f
f.o = d
i.p = e
i.s = f
n.z = m
assert g.x.s.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: A = None
        self.z: C = None
        self.w: D = None
        self.s: C = None
        self.txt = txt

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

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

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

d = A("d")
e = B("e")
b = C("b")
g = D("g")
m = E("m")
l = C("l")
f = E("f")
i = C("i")
n = A("n")

d.z = f
e.v = n
e.z = l
e.w = g
e.s = b
b.p = e
b.s = f
g.r = i
g.x = i
g.s = e
g.u = b
g.p = f
m.o = n
l.p = e
l.s = f
f.o = d
i.p = e
i.s = f
n.z = m
assert g.x.s.o.z.txt == "f"