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

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

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

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

c = A("c")
m = B("m")
b = C("b")
a = D("a")
e = D("e")
k = D("k")
g = B("g")
n = A("n")
i = B("i")
j = C("j")

c.q = n
c.x = a
m.r = n
b.o = m
b.y = m
b.q = n
b.p = g
a.v = e
a.q = c
a.y = g
e.v = k
e.q = n
e.y = m
k.v = a
k.q = c
k.y = g
g.r = c
n.q = c
n.x = k
i.r = c
j.o = m
j.q = c
j.p = i
j.y = g
assert a.v.v.y.r.x.v.v.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.x: D = None
        self.txt = txt

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

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

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

c = A("c")
m = B("m")
b = C("b")
a = D("a")
e = D("e")
k = D("k")
g = B("g")
n = A("n")
i = B("i")
j = C("j")

c.q = n
c.x = a
m.r = n
b.o = m
b.y = m
b.q = n
b.p = g
a.v = e
a.q = c
a.y = g
e.v = k
e.q = n
e.y = m
k.v = a
k.q = c
k.y = g
g.r = c
n.q = c
n.x = k
i.r = c
j.o = m
j.q = c
j.p = i
j.y = g
assert a.v.v.y.r.x.v.v.q.q.txt == "n"