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

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

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

class D:
    def __init__(self, txt: str):
        self.y: C = None
        self.t: C = None
        self.s: D = None
        self.txt = txt

c = A("c")
b = B("b")
h = C("h")
j = D("j")
m = C("m")
g = D("g")
k = C("k")
e = D("e")
d = B("d")
f = D("f")

c.q = f
b.t = h
b.w = c
h.p = d
h.u = f
h.o = b
h.z = m
j.y = h
j.t = m
j.s = g
m.p = d
m.u = j
m.o = b
m.z = h
g.y = k
g.t = h
g.s = f
k.p = d
k.o = d
k.u = g
k.z = h
e.y = m
e.t = m
e.s = f
d.t = m
d.w = c
f.y = k
f.t = h
f.s = j
assert j.s.t.o.t.z.o.t.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.y: C = None
        self.t: C = None
        self.s: D = None
        self.txt = txt

c = A("c")
b = B("b")
h = C("h")
j = D("j")
m = C("m")
g = D("g")
k = C("k")
e = D("e")
d = B("d")
f = D("f")

c.q = f
b.t = h
b.w = c
h.p = d
h.u = f
h.o = b
h.z = m
j.y = h
j.t = m
j.s = g
m.p = d
m.u = j
m.o = b
m.z = h
g.y = k
g.t = h
g.s = f
k.p = d
k.o = d
k.u = g
k.z = h
e.y = m
e.t = m
e.s = f
d.t = m
d.w = c
f.y = k
f.t = h
f.s = j
assert j.s.t.o.t.z.o.t.z.p.txt == "d"