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

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

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

b.v = a
b.r = c
c.o = a
g.o = a
h.v = l
h.r = c
a.o = l
l.o = c
j.v = l
j.r = a
n.v = a
n.r = g
assert l.o.o.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.r: B = None
        self.txt = txt

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

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

b.v = a
b.r = c
c.o = a
g.o = a
h.v = l
h.r = c
a.o = l
l.o = c
j.v = l
j.r = a
n.v = a
n.r = g
assert l.o.o.o.o.o.o.o.txt == "c"