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

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

g = A("g")
f = B("f")
h = A("h")
l = B("l")
j = B("j")

g.o = l
f.v = l
h.o = f
l.v = j
j.v = l
assert j.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

g = A("g")
f = B("f")
h = A("h")
l = B("l")
j = B("j")

g.o = l
f.v = l
h.o = f
l.v = j
j.v = l
assert j.v.v.v.v.v.txt == "l"