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

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

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

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

g = A("g")
f = B("f")
a = C("a")
l = D("l")
m = D("m")
h = D("h")
e = A("e")
k = D("k")

g.x = a
g.q = f
g.v = e
f.u = h
f.r = l
a.p = f
l.q = f
l.w = m
l.s = h
m.q = f
m.w = h
m.s = l
h.q = f
h.w = m
h.s = k
e.x = a
e.q = f
e.v = g
k.q = f
k.w = m
k.s = h
assert l.q.r.w.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.q: B = None
        self.v: A = None
        self.txt = txt

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

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

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

g = A("g")
f = B("f")
a = C("a")
l = D("l")
m = D("m")
h = D("h")
e = A("e")
k = D("k")

g.x = a
g.q = f
g.v = e
f.u = h
f.r = l
a.p = f
l.q = f
l.w = m
l.s = h
m.q = f
m.w = h
m.s = l
h.q = f
h.w = m
h.s = k
e.x = a
e.q = f
e.v = g
k.q = f
k.w = m
k.s = h
assert l.q.r.w.s.w.txt == "m"