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

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

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

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.u: B = None
        self.t: C = None
        self.txt = txt

i = A("i")
l = B("l")
a = C("a")
f = D("f")
g = C("g")
m = A("m")

i.x = m
i.v = l
i.q = f
l.v = g
l.q = i
l.t = m
a.s = l
a.t = l
f.o = l
f.u = l
f.t = a
g.s = l
g.t = l
m.x = i
m.v = l
m.q = f
assert f.o.v.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.v: B = None
        self.q: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.u: B = None
        self.t: C = None
        self.txt = txt

i = A("i")
l = B("l")
a = C("a")
f = D("f")
g = C("g")
m = A("m")

i.x = m
i.v = l
i.q = f
l.v = g
l.q = i
l.t = m
a.s = l
a.t = l
f.o = l
f.u = l
f.t = a
g.s = l
g.t = l
m.x = i
m.v = l
m.q = f
assert f.o.v.s.v.txt == "g"