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

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

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

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

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

f.s = l
f.u = l
f.q = b
h.x = a
h.y = f
h.r = g
h.w = j
j.y = n
j.z = a
g.q = e
g.x = j
g.w = f
b.x = a
b.y = l
b.r = d
b.w = j
a.x = h
a.y = e
a.r = g
a.w = j
l.s = e
l.u = e
l.q = h
e.s = l
e.q = h
e.u = f
n.q = f
n.w = f
n.x = j
d.q = f
d.w = f
d.x = j
assert b.w.z.y.q.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.q: B = None
        self.u: A = None
        self.txt = txt

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

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

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

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

f.s = l
f.u = l
f.q = b
h.x = a
h.y = f
h.r = g
h.w = j
j.y = n
j.z = a
g.q = e
g.x = j
g.w = f
b.x = a
b.y = l
b.r = d
b.w = j
a.x = h
a.y = e
a.r = g
a.w = j
l.s = e
l.u = e
l.q = h
e.s = l
e.q = h
e.u = f
n.q = f
n.w = f
n.x = j
d.q = f
d.w = f
d.x = j
assert b.w.z.y.q.x.w.txt == "j"