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

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

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

j = A("j")
k = B("k")
l = C("l")
d = C("d")
m = C("m")
e = A("e")

j.w = k
k.r = j
l.s = e
d.s = j
m.s = e
e.w = k
assert l.s.w.r.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

j = A("j")
k = B("k")
l = C("l")
d = C("d")
m = C("m")
e = A("e")

j.w = k
k.r = j
l.s = e
d.s = j
m.s = e
e.w = k
assert l.s.w.r.w.r.txt == "j"