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

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

l = A("l")
k = B("k")
h = B("h")
c = A("c")

l.r = c
k.o = l
k.v = l
h.o = l
h.v = c
c.r = l
assert h.o.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.o: A = None
        self.v: A = None
        self.txt = txt

l = A("l")
k = B("k")
h = B("h")
c = A("c")

l.r = c
k.o = l
k.v = l
h.o = l
h.v = c
c.r = l
assert h.o.r.r.r.txt == "c"