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

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

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

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

b = A("b")
h = B("h")
e = C("e")
a = D("a")
l = D("l")
f = C("f")
d = C("d")
g = C("g")
m = C("m")
i = A("i")

b.s = i
b.v = a
h.q = b
e.o = b
e.s = i
a.v = l
a.q = i
a.x = i
a.w = h
l.v = a
l.q = i
l.w = h
l.x = b
f.o = b
f.s = i
d.o = b
d.s = b
g.o = b
g.s = b
m.o = i
m.s = b
i.s = b
i.v = a
assert g.s.s.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.v: D = None
        self.txt = txt

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

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

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

b = A("b")
h = B("h")
e = C("e")
a = D("a")
l = D("l")
f = C("f")
d = C("d")
g = C("g")
m = C("m")
i = A("i")

b.s = i
b.v = a
h.q = b
e.o = b
e.s = i
a.v = l
a.q = i
a.x = i
a.w = h
l.v = a
l.q = i
l.w = h
l.x = b
f.o = b
f.s = i
d.o = b
d.s = b
g.o = b
g.s = b
m.o = i
m.s = b
i.s = b
i.v = a
assert g.s.s.v.q.txt == "i"