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

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

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

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

e = A("e")
a = B("a")
c = C("c")
b = D("b")
n = D("n")
h = B("h")
g = B("g")
k = A("k")
j = B("j")

e.p = k
a.x = h
a.t = h
a.p = e
a.y = c
c.p = j
c.q = j
c.z = b
c.s = e
b.v = g
b.q = c
n.v = g
n.q = c
h.x = g
h.t = g
h.p = e
h.y = c
g.x = a
g.t = a
g.p = e
g.y = c
k.p = e
j.x = g
j.p = e
j.y = c
j.t = a
assert b.q.s.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

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

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

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

e = A("e")
a = B("a")
c = C("c")
b = D("b")
n = D("n")
h = B("h")
g = B("g")
k = A("k")
j = B("j")

e.p = k
a.x = h
a.t = h
a.p = e
a.y = c
c.p = j
c.q = j
c.z = b
c.s = e
b.v = g
b.q = c
n.v = g
n.q = c
h.x = g
h.t = g
h.p = e
h.y = c
g.x = a
g.t = a
g.p = e
g.y = c
k.p = e
j.x = g
j.p = e
j.y = c
j.t = a
assert b.q.s.p.p.p.p.p.txt == "k"