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

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

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

e.v = h
e.q = f
c.q = a
c.s = i
m.v = g
m.q = f
i.q = f
i.s = a
g.v = e
g.q = a
n.v = g
n.q = c
f.q = a
f.s = i
h.v = m
h.q = c
a.q = c
a.s = f
assert h.v.v.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.q: B = None
        self.txt = txt

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

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

e.v = h
e.q = f
c.q = a
c.s = i
m.v = g
m.q = f
i.q = f
i.s = a
g.v = e
g.q = a
n.v = g
n.q = c
f.q = a
f.s = i
h.v = m
h.q = c
a.q = c
a.s = f
assert h.v.v.q.q.txt == "c"