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

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

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

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

n = A("n")
l = B("l")
m = C("m")
e = D("e")
j = A("j")

n.v = j
l.w = e
m.r = n
e.y = j
e.s = j
j.v = n
assert m.r.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

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

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

n = A("n")
l = B("l")
m = C("m")
e = D("e")
j = A("j")

n.v = j
l.w = e
m.r = n
e.y = j
e.s = j
j.v = n
assert m.r.v.v.v.v.txt == "n"