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

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

g = A("g")
i = B("i")
f = B("f")
a = A("a")
b = A("b")
l = B("l")
k = A("k")
j = B("j")
e = B("e")
n = B("n")

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

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

g = A("g")
i = B("i")
f = B("f")
a = A("a")
b = A("b")
l = B("l")
k = A("k")
j = B("j")
e = B("e")
n = B("n")

g.r = b
g.v = a
i.q = f
f.q = j
a.r = g
a.v = b
b.r = g
b.v = a
l.q = e
k.r = a
k.v = g
j.q = e
e.q = l
n.q = f
assert e.q.q.q.q.txt == "e"