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

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

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

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

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

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

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

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

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

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

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

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

l.o = h
j.w = g
m.w = b
m.p = k
m.s = l
m.q = a
g.s = b
g.x = b
b.u = l
h.u = l
k.s = b
k.x = b
a.w = h
a.p = k
a.s = l
a.q = m
i.w = g
assert h.u.o.u.o.u.o.txt == "h"