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

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

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

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

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

e = A("e")
n = B("n")
d = C("d")
h = D("h")
g = E("g")
i = A("i")
b = E("b")

e.t = n
e.s = g
e.x = d
n.w = i
n.s = e
n.r = b
d.q = h
h.r = e
g.s = e
i.t = n
i.s = g
i.x = d
b.s = i
assert g.s.s.s.s.s.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.s: E = None
        self.x: C = None
        self.txt = txt

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

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

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

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

e = A("e")
n = B("n")
d = C("d")
h = D("h")
g = E("g")
i = A("i")
b = E("b")

e.t = n
e.s = g
e.x = d
n.w = i
n.s = e
n.r = b
d.q = h
h.r = e
g.s = e
i.t = n
i.s = g
i.x = d
b.s = i
assert g.s.s.s.s.s.x.q.txt == "h"