class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.y: A = None
        self.v: C = None
        self.r: A = None
        self.txt = txt

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

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

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

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

k.w = n
k.y = c
k.r = c
k.v = b
j.x = c
j.z = k
j.o = g
a.q = k
n.s = h
n.q = b
h.q = k
f.s = a
f.q = h
e.s = b
e.q = h
g.x = k
g.z = k
g.o = j
c.w = n
c.y = k
c.r = k
c.v = b
b.q = c
assert c.w.s.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.y: A = None
        self.v: C = None
        self.r: A = None
        self.txt = txt

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

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

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

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

k.w = n
k.y = c
k.r = c
k.v = b
j.x = c
j.z = k
j.o = g
a.q = k
n.s = h
n.q = b
h.q = k
f.s = a
f.q = h
e.s = b
e.q = h
g.x = k
g.z = k
g.o = j
c.w = n
c.y = k
c.r = k
c.v = b
b.q = c
assert c.w.s.q.w.txt == "n"