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

class B:
    def __init__(self, txt: str):
        self.v: B = None
        self.u: B = None
        self.txt = txt

h = A("h")
i = B("i")
l = A("l")
m = A("m")
e = A("e")
g = B("g")
j = B("j")
n = A("n")
b = B("b")
a = A("a")

h.r = n
h.q = j
i.v = g
i.u = g
l.r = a
l.q = b
m.r = n
m.q = g
e.r = h
e.q = b
g.v = j
g.u = j
j.v = g
j.u = g
n.r = h
n.q = i
b.v = j
b.u = i
a.r = n
a.q = j
assert n.r.q.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.q: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: B = None
        self.u: B = None
        self.txt = txt

h = A("h")
i = B("i")
l = A("l")
m = A("m")
e = A("e")
g = B("g")
j = B("j")
n = A("n")
b = B("b")
a = A("a")

h.r = n
h.q = j
i.v = g
i.u = g
l.r = a
l.q = b
m.r = n
m.q = g
e.r = h
e.q = b
g.v = j
g.u = j
j.v = g
j.u = g
n.r = h
n.q = i
b.v = j
b.u = i
a.r = n
a.q = j
assert n.r.q.v.v.txt == "j"