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

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

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

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

l = A("l")
b = B("b")
d = C("d")
f = D("f")
g = C("g")
n = B("n")
a = C("a")
i = A("i")

l.x = a
l.p = a
l.y = i
b.z = f
b.y = f
b.v = g
b.q = d
d.q = f
d.p = f
d.s = i
d.x = n
f.o = l
g.q = f
g.p = f
g.s = l
g.x = b
n.z = f
n.y = f
n.v = d
n.q = a
a.q = f
a.p = f
a.s = l
a.x = b
i.x = a
i.y = l
i.p = d
assert d.x.v.s.y.x.q.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: A = None
        self.p: C = None
        self.txt = txt

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

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

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

l = A("l")
b = B("b")
d = C("d")
f = D("f")
g = C("g")
n = B("n")
a = C("a")
i = A("i")

l.x = a
l.p = a
l.y = i
b.z = f
b.y = f
b.v = g
b.q = d
d.q = f
d.p = f
d.s = i
d.x = n
f.o = l
g.q = f
g.p = f
g.s = l
g.x = b
n.z = f
n.y = f
n.v = d
n.q = a
a.q = f
a.p = f
a.s = l
a.x = b
i.x = a
i.y = l
i.p = d
assert d.x.v.s.y.x.q.o.y.txt == "i"