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

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.v: B = None
        self.o: A = None
        self.w: A = None
        self.txt = txt

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.v: B = None
        self.o: A = None
        self.w: A = None
        self.txt = txt

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

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

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

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