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

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

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

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

c = A("c")
h = B("h")
i = C("i")
k = D("k")
l = D("l")
m = C("m")
b = A("b")
g = B("g")
e = D("e")

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

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

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

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

c = A("c")
h = B("h")
i = C("i")
k = D("k")
l = D("l")
m = C("m")
b = A("b")
g = B("g")
e = D("e")

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