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

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

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

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

c = A("c")
h = B("h")
n = C("n")
d = D("d")
j = C("j")
l = A("l")
g = A("g")
k = D("k")
a = B("a")
f = A("f")

c.y = n
c.q = j
h.o = d
h.x = a
h.p = k
n.w = g
d.s = k
d.v = k
j.w = f
l.y = j
l.q = j
g.y = n
g.q = n
k.s = d
k.v = d
a.o = k
a.p = k
a.x = h
f.y = n
f.q = n
assert n.w.q.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.q: C = None
        self.txt = txt

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

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

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

c = A("c")
h = B("h")
n = C("n")
d = D("d")
j = C("j")
l = A("l")
g = A("g")
k = D("k")
a = B("a")
f = A("f")

c.y = n
c.q = j
h.o = d
h.x = a
h.p = k
n.w = g
d.s = k
d.v = k
j.w = f
l.y = j
l.q = j
g.y = n
g.q = n
k.s = d
k.v = d
a.o = k
a.p = k
a.x = h
f.y = n
f.q = n
assert n.w.q.w.q.txt == "n"