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

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

e = A("e")
n = B("n")
f = A("f")
i = B("i")

e.r = f
e.p = n
n.v = f
n.x = i
f.r = e
f.p = i
i.v = f
i.x = n
assert f.r.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.p: B = None
        self.txt = txt

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

e = A("e")
n = B("n")
f = A("f")
i = B("i")

e.r = f
e.p = n
n.v = f
n.x = i
f.r = e
f.p = i
i.v = f
i.x = n
assert f.r.p.x.txt == "i"