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

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

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

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

e = A("e")
i = B("i")
g = C("g")
d = D("d")
a = B("a")
f = D("f")

e.o = i
e.z = g
i.s = g
i.u = e
g.q = e
d.p = g
d.q = f
d.v = e
d.o = e
a.s = g
a.u = e
f.p = g
f.q = d
f.v = e
f.o = e
assert f.v.z.q.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.z: C = None
        self.txt = txt

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

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

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

e = A("e")
i = B("i")
g = C("g")
d = D("d")
a = B("a")
f = D("f")

e.o = i
e.z = g
i.s = g
i.u = e
g.q = e
d.p = g
d.q = f
d.v = e
d.o = e
a.s = g
a.u = e
f.p = g
f.q = d
f.v = e
f.o = e
assert f.v.z.q.z.q.txt == "e"