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

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

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

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

k = A("k")
c = B("c")
g = C("g")
d = D("d")
h = D("h")
j = A("j")
n = A("n")

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

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

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

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

k = A("k")
c = B("c")
g = C("g")
d = D("d")
h = D("h")
j = A("j")
n = A("n")

k.z = j
k.w = j
k.r = c
c.u = g
g.w = k
g.o = c
d.q = k
d.s = c
d.o = c
h.q = j
h.s = c
h.o = c
j.z = k
j.w = n
j.r = c
n.z = j
n.w = j
n.r = c
assert j.r.u.o.u.w.z.z.txt == "k"