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

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

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

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

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

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

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

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

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

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

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

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

m.p = i
i.u = j
i.q = h
i.s = k
d.t = j
j.v = k
j.u = m
j.r = m
j.q = a
k.q = m
k.p = j
k.x = j
k.s = a
b.p = h
g.t = j
a.q = b
a.p = j
a.x = j
a.s = k
h.u = j
h.q = i
h.s = k
assert k.s.q.p.q.s.s.s.q.txt == "m"