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

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

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

class D:
    def __init__(self, txt: str):
        self.s: E = None
        self.r: B = None
        self.q: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: A = None
        self.u: A = None
        self.o: C = None
        self.txt = txt

n = A("n")
d = B("d")
m = C("m")
e = D("e")
b = E("b")
k = D("k")
h = D("h")
g = A("g")
a = B("a")

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

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

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

class D:
    def __init__(self, txt: str):
        self.s: E = None
        self.r: B = None
        self.q: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: A = None
        self.u: A = None
        self.o: C = None
        self.txt = txt

n = A("n")
d = B("d")
m = C("m")
e = D("e")
b = E("b")
k = D("k")
h = D("h")
g = A("g")
a = B("a")

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