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

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

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

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

g = A("g")
l = B("l")
h = C("h")
b = D("b")
d = D("d")
f = D("f")
k = D("k")
i = A("i")
c = D("c")

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

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

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

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

g = A("g")
l = B("l")
h = C("h")
b = D("b")
d = D("d")
f = D("f")
k = D("k")
i = A("i")
c = D("c")

g.x = i
g.o = h
g.s = l
l.q = f
l.w = c
l.p = d
h.v = l
b.v = l
b.s = l
b.w = l
d.v = l
d.s = l
d.w = l
f.v = l
f.s = l
f.w = l
k.v = l
k.s = l
k.w = l
i.x = g
i.o = h
i.s = l
c.v = l
c.s = l
c.w = l
assert g.s.p.v.p.v.q.v.p.w.txt == "l"