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

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.x: C = None
        self.txt = txt

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

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

a = A("a")
h = B("h")
n = C("n")
b = D("b")
g = C("g")
c = B("c")

a.v = b
a.u = b
h.s = a
h.x = g
n.t = a
n.z = g
b.t = h
g.t = a
g.z = n
c.s = a
c.x = g
assert a.v.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.u: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.x: C = None
        self.txt = txt

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

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

a = A("a")
h = B("h")
n = C("n")
b = D("b")
g = C("g")
c = B("c")

a.v = b
a.u = b
h.s = a
h.x = g
n.t = a
n.z = g
b.t = h
g.t = a
g.z = n
c.s = a
c.x = g
assert a.v.t.x.txt == "g"