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

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

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

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

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

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

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

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

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

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

a.u = h
a.q = n
i.w = n
h.o = j
h.y = i
h.z = i
j.u = n
j.v = l
j.r = k
f.u = n
f.v = k
f.r = a
l.u = h
l.q = i
n.w = i
b.u = n
b.v = l
b.r = l
k.u = h
k.q = n
g.u = n
g.v = a
g.r = k
assert b.u.w.w.w.w.txt == "n"