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

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

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

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

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

k.o = i
k.r = n
n.s = i
n.u = k
l.w = n
l.r = n
j.o = k
j.y = k
j.r = k
j.p = n
i.w = n
i.r = n
assert j.p.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.r: B = None
        self.txt = txt

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

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

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

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

k.o = i
k.r = n
n.s = i
n.u = k
l.w = n
l.r = n
j.o = k
j.y = k
j.r = k
j.p = n
i.w = n
i.r = n
assert j.p.u.o.txt == "i"