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

class B:
    def __init__(self, txt: str):
        self.z: C = None
        self.y: D = None
        self.r: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.q: B = None
        self.u: C = None
        self.r: B = None
        self.txt = txt

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

h = A("h")
j = B("j")
d = C("d")
e = D("e")
f = B("f")
m = C("m")

h.u = e
h.s = d
h.z = d
j.z = d
j.r = d
j.y = e
d.q = j
d.u = m
d.r = f
e.u = f
e.p = f
e.x = h
f.z = d
f.r = d
f.y = e
m.q = j
m.u = d
m.r = f
assert f.z.r.r.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.s: C = None
        self.z: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: C = None
        self.y: D = None
        self.r: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.q: B = None
        self.u: C = None
        self.r: B = None
        self.txt = txt

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

h = A("h")
j = B("j")
d = C("d")
e = D("e")
f = B("f")
m = C("m")

h.u = e
h.s = d
h.z = d
j.z = d
j.r = d
j.y = e
d.q = j
d.u = m
d.r = f
e.u = f
e.p = f
e.x = h
f.z = d
f.r = d
f.y = e
m.q = j
m.u = d
m.r = f
assert f.z.r.r.u.u.txt == "d"