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

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.v: D = None
        self.t: C = None
        self.y: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

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

l = A("l")
a = B("a")
n = C("n")
f = D("f")

l.w = n
l.x = f
l.r = a
a.q = l
a.v = f
a.t = n
a.y = n
n.t = f
f.w = n
f.y = n
assert n.t.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.x: D = None
        self.r: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.v: D = None
        self.t: C = None
        self.y: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

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

l = A("l")
a = B("a")
n = C("n")
f = D("f")

l.w = n
l.x = f
l.r = a
a.q = l
a.v = f
a.t = n
a.y = n
n.t = f
f.w = n
f.y = n
assert n.t.w.t.txt == "f"