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

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

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

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

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

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

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

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

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

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

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