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

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

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

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

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

b.x = f
g.v = m
f.t = m
f.z = b
m.v = n
m.s = n
m.w = f
m.u = b
a.t = n
a.z = b
h.t = n
h.z = b
n.v = m
n.s = m
n.w = h
n.u = b
e.t = n
e.z = b
i.v = n
assert i.v.v.v.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

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

b.x = f
g.v = m
f.t = m
f.z = b
m.v = n
m.s = n
m.w = f
m.u = b
a.t = n
a.z = b
h.t = n
h.z = b
n.v = m
n.s = m
n.w = h
n.u = b
e.t = n
e.z = b
i.v = n
assert i.v.v.v.u.x.txt == "f"