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

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

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

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

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

g = A("g")
a = B("a")
j = C("j")
h = D("h")
e = E("e")
n = E("n")
i = A("i")
b = C("b")
m = A("m")
f = D("f")

g.w = a
g.x = n
a.u = m
a.w = m
a.p = n
a.o = n
j.u = a
j.o = f
j.p = i
h.u = f
h.y = f
e.o = n
n.o = e
i.w = a
i.x = n
b.u = a
b.o = h
b.p = m
m.w = a
m.x = n
f.u = h
f.y = h
assert f.y.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: E = None
        self.txt = txt

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

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

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

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

g = A("g")
a = B("a")
j = C("j")
h = D("h")
e = E("e")
n = E("n")
i = A("i")
b = C("b")
m = A("m")
f = D("f")

g.w = a
g.x = n
a.u = m
a.w = m
a.p = n
a.o = n
j.u = a
j.o = f
j.p = i
h.u = f
h.y = f
e.o = n
n.o = e
i.w = a
i.x = n
b.u = a
b.o = h
b.p = m
m.w = a
m.x = n
f.u = h
f.y = h
assert f.y.u.u.u.u.txt == "h"