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

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

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

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

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

k.o = g
k.x = g
k.p = d
k.q = d
g.o = n
g.u = k
g.s = d
d.w = n
d.y = n
d.o = j
d.x = g
n.t = d
n.w = j
n.v = g
n.x = i
i.t = d
i.w = j
i.v = j
i.x = n
j.o = n
j.u = k
j.s = d
assert k.x.s.w.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.x: B = None
        self.p: C = None
        self.q: C = None
        self.txt = txt

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

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

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

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

k.o = g
k.x = g
k.p = d
k.q = d
g.o = n
g.u = k
g.s = d
d.w = n
d.y = n
d.o = j
d.x = g
n.t = d
n.w = j
n.v = g
n.x = i
i.t = d
i.w = j
i.v = j
i.x = n
j.o = n
j.u = k
j.s = d
assert k.x.s.w.w.s.txt == "d"