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

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

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

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

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

a = A("a")
k = B("k")
n = C("n")
e = D("e")
f = E("f")
h = D("h")
i = C("i")

a.r = e
a.s = n
a.u = f
a.z = f
a.p = i
k.r = a
k.u = e
k.x = e
k.z = h
n.q = a
n.v = h
e.z = f
e.v = f
e.s = f
f.s = h
h.z = f
h.v = f
h.s = f
i.q = a
i.v = h
assert f.s.v.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.s: C = None
        self.u: E = None
        self.p: C = None
        self.z: E = None
        self.txt = txt

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

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

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

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

a = A("a")
k = B("k")
n = C("n")
e = D("e")
f = E("f")
h = D("h")
i = C("i")

a.r = e
a.s = n
a.u = f
a.z = f
a.p = i
k.r = a
k.u = e
k.x = e
k.z = h
n.q = a
n.v = h
e.z = f
e.v = f
e.s = f
f.s = h
h.z = f
h.v = f
h.s = f
i.q = a
i.v = h
assert f.s.v.s.v.txt == "f"