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

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

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

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

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

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

k.v = i
k.y = g
g.u = k
g.w = j
j.v = k
j.y = g
i.v = j
i.y = g
assert i.v.v.y.u.txt == "k"