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

class B:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

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

e.v = d
e.q = h
e.p = g
b.t = g
g.r = h
g.y = h
g.x = e
g.v = d
h.u = g
h.o = e
h.z = b
d.t = g
assert e.v.t.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.q: D = None
        self.p: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

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

e.v = d
e.q = h
e.p = g
b.t = g
g.r = h
g.y = h
g.x = e
g.v = d
h.u = g
h.o = e
h.z = b
d.t = g
assert e.v.t.x.v.txt == "d"