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

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

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

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

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

n.y = f
n.w = l
l.p = m
l.y = f
f.q = m
f.o = m
f.r = n
f.v = l
m.p = f
m.y = n
assert n.y.o.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.w: B = None
        self.txt = txt

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

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

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

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

n.y = f
n.w = l
l.p = m
l.y = f
f.q = m
f.o = m
f.r = n
f.v = l
m.p = f
m.y = n
assert n.y.o.y.y.txt == "f"