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

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

e = A("e")
k = B("k")
f = A("f")
l = B("l")
d = B("d")

e.r = f
k.v = l
k.u = d
f.r = e
l.v = k
l.u = d
d.v = k
d.u = k
assert e.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

e = A("e")
k = B("k")
f = A("f")
l = B("l")
d = B("d")

e.r = f
k.v = l
k.u = d
f.r = e
l.v = k
l.u = d
d.v = k
d.u = k
assert e.r.r.r.r.r.txt == "f"