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

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

b = A("b")
g = B("g")
d = B("d")
f = B("f")
j = A("j")
i = B("i")
c = A("c")
k = B("k")
e = A("e")
l = A("l")

b.q = c
g.v = i
g.w = l
d.v = i
d.w = c
f.v = g
f.w = c
j.q = b
i.v = d
i.w = j
c.q = j
k.v = d
k.w = b
e.q = l
l.q = e
assert l.q.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

b = A("b")
g = B("g")
d = B("d")
f = B("f")
j = A("j")
i = B("i")
c = A("c")
k = B("k")
e = A("e")
l = A("l")

b.q = c
g.v = i
g.w = l
d.v = i
d.w = c
f.v = g
f.w = c
j.q = b
i.v = d
i.w = j
c.q = j
k.v = d
k.w = b
e.q = l
l.q = e
assert l.q.q.q.q.q.q.txt == "l"