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

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

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

j = A("j")
i = B("i")
a = C("a")
h = A("h")
m = B("m")
c = C("c")
b = C("b")
n = B("n")
d = A("d")

j.y = c
j.x = c
j.w = m
i.p = j
i.w = d
a.o = c
a.s = i
a.q = h
h.y = b
h.x = b
h.w = m
m.p = j
m.w = h
c.o = b
c.s = m
c.q = j
b.o = c
b.s = n
b.q = h
n.p = j
n.w = j
d.y = b
d.x = a
d.w = m
assert b.q.x.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.x: C = None
        self.w: B = None
        self.txt = txt

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

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

j = A("j")
i = B("i")
a = C("a")
h = A("h")
m = B("m")
c = C("c")
b = C("b")
n = B("n")
d = A("d")

j.y = c
j.x = c
j.w = m
i.p = j
i.w = d
a.o = c
a.s = i
a.q = h
h.y = b
h.x = b
h.w = m
m.p = j
m.w = h
c.o = b
c.s = m
c.q = j
b.o = c
b.s = n
b.q = h
n.p = j
n.w = j
d.y = b
d.x = a
d.w = m
assert b.q.x.o.s.txt == "m"