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

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

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

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

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

n.o = k
n.r = k
n.y = b
k.t = f
k.q = n
k.s = n
f.z = i
f.v = i
f.p = b
e.x = f
b.o = k
b.r = k
b.y = n
i.z = f
i.v = f
i.p = n
assert k.t.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.y: A = None
        self.r: B = None
        self.txt = txt

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

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

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

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

n.o = k
n.r = k
n.y = b
k.t = f
k.q = n
k.s = n
f.z = i
f.v = i
f.p = b
e.x = f
b.o = k
b.r = k
b.y = n
i.z = f
i.v = f
i.p = n
assert k.t.p.y.txt == "n"