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

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

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

k = A("k")
i = B("i")
f = C("f")
n = A("n")
g = A("g")
b = A("b")
j = B("j")
h = A("h")
m = C("m")

k.s = i
k.w = j
i.s = h
i.q = g
i.r = n
f.x = m
f.o = k
f.t = n
n.s = i
n.w = i
g.s = j
g.w = j
b.s = j
b.w = i
j.s = g
j.r = g
j.q = b
h.s = j
h.w = j
m.x = f
m.o = k
m.t = n
assert f.o.s.q.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.w: B = None
        self.txt = txt

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

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

k = A("k")
i = B("i")
f = C("f")
n = A("n")
g = A("g")
b = A("b")
j = B("j")
h = A("h")
m = C("m")

k.s = i
k.w = j
i.s = h
i.q = g
i.r = n
f.x = m
f.o = k
f.t = n
n.s = i
n.w = i
g.s = j
g.w = j
b.s = j
b.w = i
j.s = g
j.r = g
j.q = b
h.s = j
h.w = j
m.x = f
m.o = k
m.t = n
assert f.o.s.q.w.q.txt == "b"