class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.r: B = None
        self.o: D = None
        self.txt = txt

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

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

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

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

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

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

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

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

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

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