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

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

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

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

k = A("k")
j = B("j")
i = C("i")
d = D("d")
n = C("n")
b = A("b")
h = B("h")
c = A("c")

k.q = n
j.q = k
j.u = d
i.v = d
d.o = c
d.x = j
d.q = j
d.y = h
n.v = d
b.q = i
h.q = c
h.u = d
c.q = n
assert n.v.x.q.q.v.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

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

k = A("k")
j = B("j")
i = C("i")
d = D("d")
n = C("n")
b = A("b")
h = B("h")
c = A("c")

k.q = n
j.q = k
j.u = d
i.v = d
d.o = c
d.x = j
d.q = j
d.y = h
n.v = d
b.q = i
h.q = c
h.u = d
c.q = n
assert n.v.x.q.q.v.y.q.txt == "c"