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

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

f = A("f")
b = B("b")
i = A("i")
m = A("m")
h = A("h")
j = A("j")
c = B("c")
g = B("g")

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

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

f = A("f")
b = B("b")
i = A("i")
m = A("m")
h = A("h")
j = A("j")
c = B("c")
g = B("g")

f.q = b
f.v = i
b.s = i
b.w = g
i.q = c
i.v = j
m.q = c
m.v = f
h.q = b
h.v = j
j.q = g
j.v = m
c.s = i
c.w = g
g.s = j
g.w = c
assert c.s.v.v.q.w.s.v.q.txt == "c"