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

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

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

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

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

h = A("h")
e = B("e")
b = C("b")
c = D("c")
n = E("n")
m = B("m")
g = A("g")

h.w = g
e.t = n
e.u = c
e.p = h
b.u = c
c.r = h
c.q = g
c.s = m
c.o = e
n.r = g
n.p = e
n.x = h
m.t = n
m.u = c
m.p = h
g.w = h
assert b.u.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

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

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

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

h = A("h")
e = B("e")
b = C("b")
c = D("c")
n = E("n")
m = B("m")
g = A("g")

h.w = g
e.t = n
e.u = c
e.p = h
b.u = c
c.r = h
c.q = g
c.s = m
c.o = e
n.r = g
n.p = e
n.x = h
m.t = n
m.u = c
m.p = h
g.w = h
assert b.u.q.w.txt == "h"