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

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

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

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

f = A("f")
k = B("k")
e = C("e")
n = D("n")

f.u = n
k.r = e
e.y = k
e.r = k
e.p = f
n.u = f
assert n.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

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

f = A("f")
k = B("k")
e = C("e")
n = D("n")

f.u = n
k.r = e
e.y = k
e.r = k
e.p = f
n.u = f
assert n.u.u.u.u.txt == "n"