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

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

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

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

k = A("k")
n = B("n")
e = C("e")
i = D("i")
j = C("j")
l = C("l")

k.y = j
n.t = e
n.p = e
e.o = k
i.o = k
i.y = n
i.x = n
j.o = k
l.o = k
assert i.y.t.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

k = A("k")
n = B("n")
e = C("e")
i = D("i")
j = C("j")
l = C("l")

k.y = j
n.t = e
n.p = e
e.o = k
i.o = k
i.y = n
i.x = n
j.o = k
l.o = k
assert i.y.t.o.y.txt == "j"