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

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

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

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

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

h.o = f
h.p = n
a.s = n
f.u = n
f.t = n
f.x = a
n.s = a
n.r = h
n.v = m
m.u = n
m.t = n
m.x = a
assert h.o.u.v.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.p: D = None
        self.txt = txt

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

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

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

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

h.o = f
h.p = n
a.s = n
f.u = n
f.t = n
f.x = a
n.s = a
n.r = h
n.v = m
m.u = n
m.t = n
m.x = a
assert h.o.u.v.x.s.txt == "n"