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

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

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

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

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

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

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

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

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

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

e.y = a
a.z = h
a.v = b
a.r = f
a.w = f
f.v = e
g.t = h
g.z = f
g.q = a
g.o = b
h.y = a
b.t = e
b.z = f
b.q = a
b.o = g
assert a.z.y.r.v.y.z.txt == "h"