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

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

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

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

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

b.q = d
b.x = f
b.w = h
f.w = h
f.v = i
k.s = d
k.u = d
k.w = h
e.y = g
e.w = f
e.x = k
i.s = b
i.w = b
i.u = d
d.q = b
d.w = b
d.x = f
g.y = e
g.w = f
g.x = a
m.s = h
m.w = d
m.u = d
h.q = b
h.x = f
h.w = d
a.s = h
a.w = d
a.u = d
assert b.x.v.u.x.w.x.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.x: B = None
        self.w: A = None
        self.txt = txt

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

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

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

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

b.q = d
b.x = f
b.w = h
f.w = h
f.v = i
k.s = d
k.u = d
k.w = h
e.y = g
e.w = f
e.x = k
i.s = b
i.w = b
i.u = d
d.q = b
d.w = b
d.x = f
g.y = e
g.w = f
g.x = a
m.s = h
m.w = d
m.u = d
h.q = b
h.x = f
h.w = d
a.s = h
a.w = d
a.u = d
assert b.x.v.u.x.w.x.v.s.txt == "b"