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

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

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

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

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

b = A("b")
e = B("e")
l = C("l")
h = D("h")
c = E("c")
a = B("a")
g = C("g")

b.x = h
e.r = g
e.y = b
e.s = b
e.x = l
l.x = h
l.z = h
l.q = h
l.y = c
h.w = c
h.p = c
h.o = b
h.x = g
h.u = l
c.q = e
a.r = l
a.x = l
a.y = b
a.s = b
g.x = h
g.z = h
g.q = h
g.y = c
assert c.q.x.z.x.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

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

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

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

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

b = A("b")
e = B("e")
l = C("l")
h = D("h")
c = E("c")
a = B("a")
g = C("g")

b.x = h
e.r = g
e.y = b
e.s = b
e.x = l
l.x = h
l.z = h
l.q = h
l.y = c
h.w = c
h.p = c
h.o = b
h.x = g
h.u = l
c.q = e
a.r = l
a.x = l
a.y = b
a.s = b
g.x = h
g.z = h
g.q = h
g.y = c
assert c.q.x.z.x.y.q.txt == "e"