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

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

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

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

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

d = A("d")
m = B("m")
g = C("g")
f = D("f")
j = E("j")

d.x = f
d.v = j
m.q = j
g.v = f
g.u = j
g.y = d
g.q = m
f.x = d
j.y = m
j.v = m
j.p = m
j.s = d
j.o = f
assert j.o.x.v.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.v: E = None
        self.txt = txt

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

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

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

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

d = A("d")
m = B("m")
g = C("g")
f = D("f")
j = E("j")

d.x = f
d.v = j
m.q = j
g.v = f
g.u = j
g.y = d
g.q = m
f.x = d
j.y = m
j.v = m
j.p = m
j.s = d
j.o = f
assert j.o.x.v.s.v.txt == "j"