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

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

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

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

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

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

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

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

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

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

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