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

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

class C:
    def __init__(self, txt: str):
        self.z: E = None
        self.r: D = None
        self.txt = txt

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

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

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

b.w = i
b.s = i
b.x = g
a.w = b
a.x = j
g.z = k
g.r = j
j.r = e
j.p = m
k.q = a
k.u = g
f.q = a
f.u = g
m.z = f
m.r = j
e.w = b
e.s = i
e.x = g
i.w = e
i.s = b
i.x = g
assert g.z.u.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.s: A = None
        self.x: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.z: E = None
        self.r: D = None
        self.txt = txt

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

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

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

b.w = i
b.s = i
b.x = g
a.w = b
a.x = j
g.z = k
g.r = j
j.r = e
j.p = m
k.q = a
k.u = g
f.q = a
f.u = g
m.z = f
m.r = j
e.w = b
e.s = i
e.x = g
i.w = e
i.s = b
i.x = g
assert g.z.u.z.q.txt == "a"