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

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

class C:
    def __init__(self, txt: str):
        self.y: D = None
        self.w: B = None
        self.z: D = None
        self.p: A = None
        self.txt = txt

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

e = A("e")
b = B("b")
g = C("g")
d = D("d")
j = A("j")

e.z = j
e.q = d
e.o = d
e.w = g
b.v = j
g.y = d
g.z = d
g.w = b
g.p = e
d.v = g
j.z = e
j.q = d
j.o = d
j.w = g
assert j.z.q.v.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.q: D = None
        self.w: C = None
        self.o: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.y: D = None
        self.w: B = None
        self.z: D = None
        self.p: A = None
        self.txt = txt

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

e = A("e")
b = B("b")
g = C("g")
d = D("d")
j = A("j")

e.z = j
e.q = d
e.o = d
e.w = g
b.v = j
g.y = d
g.z = d
g.w = b
g.p = e
d.v = g
j.z = e
j.q = d
j.o = d
j.w = g
assert j.z.q.v.y.v.txt == "g"