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

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

a = A("a")
j = B("j")
b = B("b")
g = A("g")
l = B("l")
h = B("h")
c = A("c")
k = B("k")
m = B("m")

a.y = l
a.v = c
j.q = b
j.w = h
b.q = m
b.w = k
g.y = l
g.v = c
l.q = j
l.w = h
h.q = k
h.w = k
c.y = j
c.v = g
k.q = h
k.w = m
m.q = k
m.w = b
assert k.w.w.w.w.q.q.q.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.v: A = None
        self.txt = txt

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

a = A("a")
j = B("j")
b = B("b")
g = A("g")
l = B("l")
h = B("h")
c = A("c")
k = B("k")
m = B("m")

a.y = l
a.v = c
j.q = b
j.w = h
b.q = m
b.w = k
g.y = l
g.v = c
l.q = j
l.w = h
h.q = k
h.w = k
c.y = j
c.v = g
k.q = h
k.w = m
m.q = k
m.w = b
assert k.w.w.w.w.q.q.q.w.w.txt == "b"