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

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

n = A("n")
m = B("m")
f = A("f")
c = A("c")
e = A("e")
k = A("k")
h = A("h")
i = A("i")
j = B("j")
g = A("g")

n.w = g
n.u = e
m.w = j
m.q = j
f.w = c
f.u = h
c.w = i
c.u = i
e.w = h
e.u = f
k.w = i
k.u = g
h.w = g
h.u = k
i.w = k
i.u = g
j.w = m
j.q = m
g.w = n
g.u = h
assert j.w.q.w.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.u: A = None
        self.txt = txt

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

n = A("n")
m = B("m")
f = A("f")
c = A("c")
e = A("e")
k = A("k")
h = A("h")
i = A("i")
j = B("j")
g = A("g")

n.w = g
n.u = e
m.w = j
m.q = j
f.w = c
f.u = h
c.w = i
c.u = i
e.w = h
e.u = f
k.w = i
k.u = g
h.w = g
h.u = k
i.w = k
i.u = g
j.w = m
j.q = m
g.w = n
g.u = h
assert j.w.q.w.w.q.txt == "m"