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

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

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

b = A("b")
g = B("g")
l = C("l")
j = C("j")
a = A("a")
n = B("n")
k = C("k")
h = C("h")
i = A("i")
d = A("d")

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

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

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

b = A("b")
g = B("g")
l = C("l")
j = C("j")
a = A("a")
n = B("n")
k = C("k")
h = C("h")
i = A("i")
d = A("d")

b.z = i
b.y = i
b.u = g
g.s = i
g.w = h
g.q = j
l.o = g
j.o = g
a.z = b
a.y = b
a.u = g
n.s = b
n.w = h
n.q = k
k.o = n
h.o = g
i.z = a
i.u = g
i.y = d
d.z = a
d.u = n
d.y = b
assert g.w.o.q.o.s.y.txt == "d"