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

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

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

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

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

d.s = a
e.q = n
e.o = d
g.s = l
g.x = e
g.v = h
g.p = c
h.x = i
h.r = n
h.s = n
i.s = a
k.s = d
a.s = i
c.s = l
c.x = l
c.v = h
c.p = g
l.q = e
l.o = a
n.q = e
n.o = d
assert g.s.o.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

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

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

d.s = a
e.q = n
e.o = d
g.s = l
g.x = e
g.v = h
g.p = c
h.x = i
h.r = n
h.s = n
i.s = a
k.s = d
a.s = i
c.s = l
c.x = l
c.v = h
c.p = g
l.q = e
l.o = a
n.q = e
n.o = d
assert g.s.o.s.s.txt == "a"