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.o: A = None
        self.txt = txt

e = A("e")
l = B("l")
d = B("d")
m = A("m")
g = B("g")
c = B("c")
k = B("k")

e.v = m
e.y = l
l.o = e
d.o = m
m.v = e
m.y = c
g.o = e
c.o = e
k.o = m
assert g.o.y.o.v.y.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.o: A = None
        self.txt = txt

e = A("e")
l = B("l")
d = B("d")
m = A("m")
g = B("g")
c = B("c")
k = B("k")

e.v = m
e.y = l
l.o = e
d.o = m
m.v = e
m.y = c
g.o = e
c.o = e
k.o = m
assert g.o.y.o.v.y.txt == "c"