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

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

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

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

d = A("d")
a = B("a")
k = C("k")
j = D("j")
g = C("g")
h = D("h")
b = B("b")
i = C("i")
m = A("m")

d.q = b
d.s = m
d.w = a
a.o = i
a.w = b
k.r = h
k.t = m
k.p = b
j.y = d
g.r = j
g.t = m
g.p = a
h.y = d
b.o = k
b.w = a
i.r = j
i.t = d
i.p = b
m.q = b
m.s = d
m.w = a
assert m.q.w.w.o.p.o.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.s: A = None
        self.w: B = None
        self.txt = txt

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

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

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

d = A("d")
a = B("a")
k = C("k")
j = D("j")
g = C("g")
h = D("h")
b = B("b")
i = C("i")
m = A("m")

d.q = b
d.s = m
d.w = a
a.o = i
a.w = b
k.r = h
k.t = m
k.p = b
j.y = d
g.r = j
g.t = m
g.p = a
h.y = d
b.o = k
b.w = a
i.r = j
i.t = d
i.p = b
m.q = b
m.s = d
m.w = a
assert m.q.w.w.o.p.o.p.txt == "b"