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

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

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

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

d.r = l
j.r = l
j.w = e
e.u = l
l.r = d
assert l.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.r: A = None
        self.w: C = None
        self.txt = txt

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

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

d.r = l
j.r = l
j.w = e
e.u = l
l.r = d
assert l.r.r.r.r.txt == "l"