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

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

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

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

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

a = A("a")
c = B("c")
n = C("n")
d = D("d")
i = E("i")
j = E("j")
b = E("b")
h = D("h")

a.x = i
c.s = a
c.u = a
c.r = i
n.o = c
n.y = c
n.v = c
d.x = i
d.y = b
i.z = a
i.p = d
j.z = a
j.p = h
b.z = a
b.p = h
h.x = b
h.y = j
assert b.z.x.z.x.z.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: E = None
        self.txt = txt

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

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

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

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

a = A("a")
c = B("c")
n = C("n")
d = D("d")
i = E("i")
j = E("j")
b = E("b")
h = D("h")

a.x = i
c.s = a
c.u = a
c.r = i
n.o = c
n.y = c
n.v = c
d.x = i
d.y = b
i.z = a
i.p = d
j.z = a
j.p = h
b.z = a
b.p = h
h.x = b
h.y = j
assert b.z.x.z.x.z.x.txt == "i"