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

class B:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

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

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

g = A("g")
l = B("l")
d = C("d")
h = D("h")
e = E("e")
c = C("c")
i = B("i")
a = E("a")
k = A("k")

g.p = k
g.s = h
g.r = d
g.t = d
l.v = h
d.o = k
d.x = h
d.v = l
h.x = a
h.u = l
h.p = e
e.r = a
c.o = k
c.x = h
c.v = l
i.v = h
a.r = e
k.p = g
k.s = h
k.r = d
k.t = c
assert d.x.p.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.s: D = None
        self.r: C = None
        self.t: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

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

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

g = A("g")
l = B("l")
d = C("d")
h = D("h")
e = E("e")
c = C("c")
i = B("i")
a = E("a")
k = A("k")

g.p = k
g.s = h
g.r = d
g.t = d
l.v = h
d.o = k
d.x = h
d.v = l
h.x = a
h.u = l
h.p = e
e.r = a
c.o = k
c.x = h
c.v = l
i.v = h
a.r = e
k.p = g
k.s = h
k.r = d
k.t = c
assert d.x.p.r.r.r.txt == "a"