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

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: B = None
        self.x: B = None
        self.txt = txt

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

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

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

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

h.y = k
k.p = m
k.y = b
k.x = b
m.u = i
m.w = c
a.q = g
g.u = a
j.u = i
j.w = c
b.p = c
b.y = k
b.x = k
i.q = g
c.u = i
c.w = m
assert b.y.x.y.x.x.y.p.w.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: B = None
        self.x: B = None
        self.txt = txt

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

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

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

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

h.y = k
k.p = m
k.y = b
k.x = b
m.u = i
m.w = c
a.q = g
g.u = a
j.u = i
j.w = c
b.p = c
b.y = k
b.x = k
i.q = g
c.u = i
c.w = m
assert b.y.x.y.x.x.y.p.w.u.txt == "i"