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

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

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

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

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

a.r = b
a.x = g
a.p = m
a.u = i
d.s = g
d.u = f
d.v = b
i.q = d
i.z = d
i.v = g
i.w = h
f.w = d
f.z = d
f.s = b
g.r = b
g.x = m
g.p = m
g.u = i
h.r = f
h.x = m
h.p = g
h.u = i
m.r = b
m.x = g
m.p = h
m.u = i
b.w = d
b.z = d
b.s = f
assert d.u.s.s.w.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.x: A = None
        self.p: A = None
        self.u: C = None
        self.txt = txt

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

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

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

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

a.r = b
a.x = g
a.p = m
a.u = i
d.s = g
d.u = f
d.v = b
i.q = d
i.z = d
i.v = g
i.w = h
f.w = d
f.z = d
f.s = b
g.r = b
g.x = m
g.p = m
g.u = i
h.r = f
h.x = m
h.p = g
h.u = i
m.r = b
m.x = g
m.p = h
m.u = i
b.w = d
b.z = d
b.s = f
assert d.u.s.s.w.v.s.txt == "f"