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

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

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

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

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

f.y = n
h.t = g
h.o = g
g.x = n
g.v = n
g.o = f
n.w = a
n.z = a
n.u = f
n.x = g
a.w = n
a.z = n
a.u = f
a.x = g
assert h.t.o.y.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

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

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

f.y = n
h.t = g
h.o = g
g.x = n
g.v = n
g.o = f
n.w = a
n.z = a
n.u = f
n.x = g
a.w = n
a.z = n
a.u = f
a.x = g
assert h.t.o.y.x.txt == "g"