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

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

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

i.r = g
m.o = g
m.v = j
b.o = c
b.v = e
g.r = i
l.o = i
l.v = k
e.o = i
e.v = l
j.o = c
j.v = m
k.o = i
k.v = b
c.r = i
assert c.r.r.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

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

i.r = g
m.o = g
m.v = j
b.o = c
b.v = e
g.r = i
l.o = i
l.v = k
e.o = i
e.v = l
j.o = c
j.v = m
k.o = i
k.v = b
c.r = i
assert c.r.r.r.r.r.r.r.r.txt == "g"