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

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

f = A("f")
l = B("l")
b = B("b")
i = A("i")
c = A("c")
j = B("j")
n = B("n")
k = B("k")

f.v = b
l.v = n
l.x = c
b.v = j
b.x = f
i.v = b
c.v = j
j.v = n
j.x = f
n.v = b
n.x = f
k.v = l
k.x = i
assert j.x.v.v.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

f = A("f")
l = B("l")
b = B("b")
i = A("i")
c = A("c")
j = B("j")
n = B("n")
k = B("k")

f.v = b
l.v = n
l.x = c
b.v = j
b.x = f
i.v = b
c.v = j
j.v = n
j.x = f
n.v = b
n.x = f
k.v = l
k.x = i
assert j.x.v.v.x.v.txt == "b"