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

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

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

class D:
    def __init__(self, txt: str):
        self.o: E = None
        self.s: D = None
        self.q: B = None
        self.w: E = None
        self.v: A = None
        self.txt = txt

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

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

h.w = i
h.x = b
i.s = h
i.x = h
i.w = d
m.v = b
m.p = h
m.o = g
e.o = d
e.w = d
e.s = b
e.q = i
e.v = h
d.u = e
d.q = i
g.v = b
g.p = h
g.o = m
b.o = d
b.w = d
b.s = e
b.q = i
b.v = h
assert i.w.u.w.u.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: E = None
        self.s: D = None
        self.q: B = None
        self.w: E = None
        self.v: A = None
        self.txt = txt

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

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

h.w = i
h.x = b
i.s = h
i.x = h
i.w = d
m.v = b
m.p = h
m.o = g
e.o = d
e.w = d
e.s = b
e.q = i
e.v = h
d.u = e
d.q = i
g.v = b
g.p = h
g.o = m
b.o = d
b.w = d
b.s = e
b.q = i
b.v = h
assert i.w.u.w.u.s.txt == "b"