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

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

k = A("k")
j = B("j")
e = A("e")
m = A("m")
i = B("i")

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

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

k = A("k")
j = B("j")
e = A("e")
m = A("m")
i = B("i")

k.v = e
j.s = e
j.v = k
e.v = m
m.v = k
i.s = e
i.v = e
assert e.v.v.v.v.v.txt == "k"