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

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

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

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

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

h.x = i
a.t = l
a.p = l
a.r = k
a.v = n
n.o = h
n.s = h
n.q = l
g.w = c
k.w = c
b.w = c
i.o = h
i.s = h
i.q = l
j.o = h
j.s = h
j.q = l
c.t = a
c.p = l
c.r = g
c.v = n
l.t = c
l.p = a
l.r = g
l.v = i
assert b.w.r.w.r.w.v.q.t.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

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

h.x = i
a.t = l
a.p = l
a.r = k
a.v = n
n.o = h
n.s = h
n.q = l
g.w = c
k.w = c
b.w = c
i.o = h
i.s = h
i.q = l
j.o = h
j.s = h
j.q = l
c.t = a
c.p = l
c.r = g
c.v = n
l.t = c
l.p = a
l.r = g
l.v = i
assert b.w.r.w.r.w.v.q.t.r.w.txt == "c"