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

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

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

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

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

h = A("h")
a = B("a")
g = C("g")
j = D("j")
k = E("k")
e = C("e")
i = A("i")

h.q = g
h.v = a
h.r = a
a.w = g
g.p = e
g.t = j
j.w = g
j.q = g
k.y = h
k.v = g
k.p = j
k.u = a
e.p = g
e.t = j
i.q = e
i.v = a
i.r = a
assert e.t.w.p.t.w.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.v: B = None
        self.r: B = None
        self.txt = txt

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

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

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

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

h = A("h")
a = B("a")
g = C("g")
j = D("j")
k = E("k")
e = C("e")
i = A("i")

h.q = g
h.v = a
h.r = a
a.w = g
g.p = e
g.t = j
j.w = g
j.q = g
k.y = h
k.v = g
k.p = j
k.u = a
e.p = g
e.t = j
i.q = e
i.v = a
i.r = a
assert e.t.w.p.t.w.t.q.txt == "g"