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

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

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

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

j = A("j")
h = B("h")
f = C("f")
b = D("b")
i = A("i")
k = C("k")
g = A("g")

j.y = f
j.q = f
j.w = i
j.o = h
h.u = f
h.r = b
h.p = i
f.z = i
f.q = k
b.y = j
b.s = h
b.z = h
i.y = f
i.q = k
i.w = j
i.o = h
k.z = g
k.q = f
g.y = k
g.q = f
g.w = i
g.o = h
assert i.w.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.q: C = None
        self.w: A = None
        self.o: B = None
        self.txt = txt

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

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

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

j = A("j")
h = B("h")
f = C("f")
b = D("b")
i = A("i")
k = C("k")
g = A("g")

j.y = f
j.q = f
j.w = i
j.o = h
h.u = f
h.r = b
h.p = i
f.z = i
f.q = k
b.y = j
b.s = h
b.z = h
i.y = f
i.q = k
i.w = j
i.o = h
k.z = g
k.q = f
g.y = k
g.q = f
g.w = i
g.o = h
assert i.w.w.q.txt == "k"