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

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

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

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

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

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

n.r = a
n.z = k
h.o = a
a.s = n
a.y = n
a.r = k
a.x = c
k.p = d
k.s = c
k.y = c
k.v = n
d.t = k
d.x = k
d.r = f
i.r = a
i.z = k
c.r = a
c.z = k
f.t = k
f.x = k
f.r = d
assert i.r.x.z.v.z.p.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.z: D = None
        self.txt = txt

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

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

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

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

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

n.r = a
n.z = k
h.o = a
a.s = n
a.y = n
a.r = k
a.x = c
k.p = d
k.s = c
k.y = c
k.v = n
d.t = k
d.x = k
d.r = f
i.r = a
i.z = k
c.r = a
c.z = k
f.t = k
f.x = k
f.r = d
assert i.r.x.z.v.z.p.x.p.txt == "d"