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

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

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

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

f = A("f")
i = B("i")
e = C("e")
g = D("g")
j = B("j")
a = D("a")
n = A("n")
m = B("m")

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

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

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

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

f = A("f")
i = B("i")
e = C("e")
g = D("g")
j = B("j")
a = D("a")
n = A("n")
m = B("m")

f.q = i
f.x = a
f.s = n
i.v = e
i.o = e
i.q = j
e.o = g
g.v = j
g.p = f
j.v = e
j.o = e
j.q = m
a.v = j
a.p = f
n.q = j
n.x = g
n.s = f
m.v = e
m.o = e
m.q = j
assert a.v.v.o.v.o.o.p.txt == "f"