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

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

f = A("f")
j = B("j")
k = B("k")
i = A("i")

f.y = i
j.v = k
j.y = f
k.v = j
k.y = i
i.y = f
assert k.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

f = A("f")
j = B("j")
k = B("k")
i = A("i")

f.y = i
j.v = k
j.y = f
k.v = j
k.y = i
i.y = f
assert k.y.y.y.txt == "i"