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

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

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

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

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

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

i.v = j
g.o = j
j.o = g
c.v = g
e.v = j
f.v = j
k.v = j
assert f.v.o.o.o.txt == "g"