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

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: B = None
        self.s: A = None
        self.txt = txt

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

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: B = None
        self.s: A = None
        self.txt = txt

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

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