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

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

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

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

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

d.q = e
a.v = b
a.z = b
a.u = d
g.w = d
g.o = d
g.r = h
h.u = a
h.o = g
h.z = e
b.v = e
b.z = e
b.u = d
e.v = a
e.u = d
e.z = b
assert h.o.w.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

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

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

d.q = e
a.v = b
a.z = b
a.u = d
g.w = d
g.o = d
g.r = h
h.u = a
h.o = g
h.z = e
b.v = e
b.z = e
b.u = d
e.v = a
e.u = d
e.z = b
assert h.o.w.q.v.txt == "a"