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

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

e = A("e")
j = B("j")
a = B("a")
n = A("n")

e.y = j
j.v = n
j.r = a
a.v = e
a.r = j
n.y = a
assert e.y.r.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

e = A("e")
j = B("j")
a = B("a")
n = A("n")

e.y = j
j.v = n
j.r = a
a.v = e
a.r = j
n.y = a
assert e.y.r.v.txt == "e"