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

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

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

e = A("e")
h = B("h")
i = C("i")
j = A("j")

e.r = j
h.s = i
h.r = i
h.w = j
i.r = j
j.r = e
assert i.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.s: C = None
        self.r: C = None
        self.w: A = None
        self.txt = txt

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

e = A("e")
h = B("h")
i = C("i")
j = A("j")

e.r = j
h.s = i
h.r = i
h.w = j
i.r = j
j.r = e
assert i.r.r.r.r.txt == "e"